<#9576 feat: Add validation to meltano state set c...
# meltano-repo-activity
g
#9576 feat: Add validation to meltano state set command Pull request opened by tayloramurphy ## Summary Adds input validation to
meltano state set
to prevent users from unknowingly setting invalid state that causes unexpected full refreshes in subsequent pipeline runs. ## Changes • CLI Validation: Added error handling to the
set_state
command that catches and surfaces validation errors with clear, actionable messages • Bypass Flag: Added
--no-validate
flag for edge cases requiring non-standard state, with appropriate warnings • Test Coverage: Added 5 comprehensive test cases covering validation scenarios • Documentation: Updated CLI reference documentation with validation behavior and examples ## Technical Details The implementation leverages the existing
StateService.validate_state()
method that checks for the required
singer_state
top-level key. Previously, this validation existed but errors were silently ignored at the CLI layer. Invalid JSON or missing required structure now produces clear error messages:
Copy code
Error: Invalid state format: singer_state not found in top level of provided state. 
State must be valid JSON with a top-level 'singer_state' key. 
Use --no-validate to bypass this check.
## Testing All new tests pass: •
test_set_invalid_json
- Validates rejection of malformed JSON •
test_set_invalid_state_format
- Validates rejection of missing
singer_state
key •
test_set_invalid_state_from_file
- Validates file input validation •
test_set_no_validate_flag
- Validates bypass flag with warning •
test_set_no_validate_from_file
- Validates bypass flag with file input Closes #6776 ## Summary by Sourcery Introduce input validation for the meltano state set command to ensure provided state is valid Singer JSON with a top-level singer_state key, add a --no-validate flag to bypass checks when necessary, and update documentation and tests to reflect these changes. New Features: • Add input validation to the meltano state set CLI command • Add a --no-validate flag to bypass state validation Enhancements: • Surface clear, actionable error messages for invalid JSON or missing singer_state key Documentation: • Update CLI reference documentation with validation behavior, warning banner, and usage examples for --no-validate Tests: • Add tests for invalid JSON and state format from both string and file inputs • Add tests for bypassing validation with --no-validate flag meltano/meltano