Skip to content

feat: add -force to bypass request schema validation - #77

Open
Bucknalla wants to merge 1 commit into
masterfrom
alex-force-flag-bypass-command-validation
Open

feat: add -force to bypass request schema validation#77
Bucknalla wants to merge 1 commit into
masterfrom
alex-force-flag-bypass-command-validation

Conversation

@Bucknalla

Copy link
Copy Markdown
Collaborator

Summary

Adds a -force flag to the notecard CLI that skips JSON schema validation of -req.

What it does

Three changes, all in notecard/main.go:

  • Registers -force alongside -dry
  • Gates the validation block: if err == nil && validateJSON && !actionForce {
  • Adds force to the comm help group — lib.PrintGroupedFlags only iterates grouped flags, so a registered-but-ungrouped flag is silently missing from -help while still building clean

Note on what "bypass" means here

Schema validation today is opt-in via the BLUES env var and is warn-only — it prints warning: ... to stderr and sends the request anyway. So -force suppresses that warning; it does not unblock a request that was previously refused, because nothing was ever refused.

The bigger practical win is network I/O: initSchema fetches the top-level schema plus every $ref live. Same invalid request, measured:

without -force:  ~50 "fetching schema:" round-trips, then
                 warning: '/bogusfield' does not validate ... not allowed
with -force:     instant, no network

That makes it useful when working offline, or against a request the published schema doesn't cover yet.

If we'd rather validation actually gate sends and -force be the override, that's a separate change — happy to follow up.

Testing

  • go build and go vet ./notecard/ clean
  • notecard -help confirmed to render -force under Communication & Debug
  • Verified end-to-end with BLUES=1 notecard -req '{"req":"card.time","bogusfield":123}' -dry -verbose with and without -force (output above)

No new tests — -dry, -nobin and the other flags don't have any either. Docs unchanged, matching the -nobin precedent (18db54f); the README doesn't enumerate flags.

Pre-existing, not addressed

-dry advertises "validate a -req but do not send it" but never gated on validation success, so -dry -force validates nothing and sends nothing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T8F6xMAoAdBizsR7cUKc4F

Add a -force flag to the notecard CLI that skips JSON schema validation
of -req. Validation is opt-in via the BLUES environment variable and is
warn-only, so -force suppresses the warning and, more usefully, skips
the live schema fetches that initSchema performs -- helpful when working
offline or against a request the published schema does not yet cover.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T8F6xMAoAdBizsR7cUKc4F
@Bucknalla
Bucknalla requested a review from zfields September 7, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant