Skip to content

feat(validation): add ADCP_VALIDATION_MODE env var for TS-SDK parity#388

Draft
bokelley wants to merge 1 commit intomainfrom
claude/issue-385-adcp-validation-mode-env-var
Draft

feat(validation): add ADCP_VALIDATION_MODE env var for TS-SDK parity#388
bokelley wants to merge 1 commit intomainfrom
claude/issue-385-adcp-validation-mode-env-var

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 3, 2026

Closes #385

Adds ADCP_VALIDATION_MODE=strict|warn|off to the validation resolution chain in client_hooks.py, matching the TS SDK contract (adcontextprotocol/adcp-client#694). Also fixes the false docstring in client.py that incorrectly claimed PYTHON_ENV / ENV / ENVIRONMENT are honored.

Precedence chain (highest → lowest):

  1. Explicit ValidationHookConfig field (per-side override)
  2. ADCP_VALIDATION_MODE env var — applies to both request and response sides
  3. ADCP_ENV legacy fallback — response side only (production / prodwarn)
  4. Hard defaults: requests "warn", responses "strict"

Changes:

  • src/adcp/validation/client_hooks.py: adds _read_validation_mode_env() helper and _VALID_MODES constant; updates resolve_validation_modes() with the new precedence chain; invalid values raise ValueError at client-construction time
  • src/adcp/client.py: docstring corrected — removes bogus PYTHON_ENV/ENV/ENVIRONMENT references, adds ADCP_VALIDATION_MODE documentation
  • tests/test_schema_validation_client.py: 7 new tests covering all three valid values, case-insensitivity, invalid value raises, explicit config wins, env var wins over ADCP_ENV, unset keeps defaults, end-to-end through ADCPClient

What 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 issues
  • ruff check — all checks passed

Pre-PR review:

  • code-reviewer: approved — no blockers; nit: _VALID_MODES duplicates ValidationMode literals (safe as-is); nit: invalid-value test directly calls _read_validation_mode_env() rather than exercising through resolve_validation_modes()
  • ad-tech-protocol-expert: approved — non-breaking per spec; nit: ValidationHookConfig class docstring predates this change and doesn't mention ADCP_VALIDATION_MODE override authority; nit: or-chain is safe with current three-value enum but would be fragile if a falsy sentinel mode were added

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01Ecbp5qb8VsWmugvD9k6HPT


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(validation): add ADCP_VALIDATION_MODE env var for JS parity

2 participants