feat(validation): add ADCP_VALIDATION_MODE env var for TS-SDK parity#388
Draft
feat(validation): add ADCP_VALIDATION_MODE env var for TS-SDK parity#388
Conversation
Adds ADCP_VALIDATION_MODE=strict|warn|off to the validation resolution chain in client_hooks.py, matching the TS SDK contract. Precedence: explicit ValidationHookConfig field > ADCP_VALIDATION_MODE > ADCP_ENV legacy > hard defaults. Fixes the client.py docstring that incorrectly claimed PYTHON_ENV/ENV/ENVIRONMENT were honored. Closes #385 https://claude.ai/code/session_01Ecbp5qb8VsWmugvD9k6HPT
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #385
Adds
ADCP_VALIDATION_MODE=strict|warn|offto the validation resolution chain inclient_hooks.py, matching the TS SDK contract (adcontextprotocol/adcp-client#694). Also fixes the false docstring inclient.pythat incorrectly claimedPYTHON_ENV/ENV/ENVIRONMENTare honored.Precedence chain (highest → lowest):
ValidationHookConfigfield (per-side override)ADCP_VALIDATION_MODEenv var — applies to both request and response sidesADCP_ENVlegacy fallback — response side only (production/prod→warn)"warn", responses"strict"Changes:
src/adcp/validation/client_hooks.py: adds_read_validation_mode_env()helper and_VALID_MODESconstant; updatesresolve_validation_modes()with the new precedence chain; invalid values raiseValueErrorat client-construction timesrc/adcp/client.py: docstring corrected — removes bogusPYTHON_ENV/ENV/ENVIRONMENTreferences, addsADCP_VALIDATION_MODEdocumentationtests/test_schema_validation_client.py: 7 new tests covering all three valid values, case-insensitivity, invalid value raises, explicit config wins, env var wins overADCP_ENV, unset keeps defaults, end-to-end throughADCPClientWhat was tested:
pytest tests/test_schema_validation_client.py— 15 passed (9 existing + 6 new parametrized + end-to-end)mypy src/adcp/validation/client_hooks.py src/adcp/client.py— no issuesruff check— all checks passedPre-PR review:
_VALID_MODESduplicatesValidationModeliterals (safe as-is); nit: invalid-value test directly calls_read_validation_mode_env()rather than exercising throughresolve_validation_modes()ValidationHookConfigclass docstring predates this change and doesn't mentionADCP_VALIDATION_MODEoverride authority; nit:or-chain is safe with current three-value enum but would be fragile if a falsy sentinel mode were addedSession: https://claude.ai/code/session_01Ecbp5qb8VsWmugvD9k6HPT
Generated by Claude Code