fix(helpers): make X-AIMock-Strict header parsing case-insensitive and whitespace-tolerant - #408
Open
Ayush7614 wants to merge 1 commit into
Open
Conversation
…d whitespace-tolerant Clients and proxies often normalize or user-configure header values with varying case (True/TRUE) or surrounding whitespace. The previous strict check compared literally against "true"/"false"/"1"/"0", so "True" or " true " silently fell through to the server default, causing surprising 404s/503s and reasoning suppression mismatches. Trim and lower-case the value before comparison so "True", "TRUE", " true " etc. are accepted. Unrecognised values still fall back to the server default.
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.
Clients, proxies, and shell snippets often emit
X-AIMock-Strict: True,TRUE, ortruewith surrounding whitespace. The previousresolveStrictModecompared literally against"true"/"false"/"1"/"0", so those variants silently fell back to the server default.On a
--strict falseserver that meantX-AIMock-Strict: Truestayed at404instead of503; on a--strict trueserverX-AIMock-Strict: Falsestayed strict. The same header also gates reasoning suppression, so the mismatch could surface as flaky reasoning assertions.Change:
"true"/"TRUE"/" True " / "1" / " 1 "→ strict on"false"/"FALSE"/" false " / "0" / " 0 "→ strict offserverDefaultVerified:
pnpm run format:check/lint/typecheckcleancreateServer:openrouter-video.test.tsstrict-header tests (lower-case) still pass (123 passed)