Validate client-level projectId in the TS and Python clients - #38
Merged
rapguit merged 1 commit intoJun 26, 2026
Merged
Conversation
Contributor
|
Going to rebase this on top of current |
Per-session projectId is validated against ^prj_[A-Za-z0-9]{16}$ (Zod
in types.ts), but the client-level projectId was passed straight to the
x-codespar-project header with no validation, in both the TS and Python
clients. A malformed client-level scope reached the backend instead of
failing fast.
Extracts PROJECT_ID_REGEX in types.ts (reused by the Zod schema and the
TS constructor) and adds the matching _PROJECT_ID_RE check to the
Python AsyncCodeSpar constructor (covers the sync client via its
factory). Fixes three Python test fixtures that used 17-char ids.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rapguit
force-pushed
the
fix/sdk-validate-client-project-id
branch
from
June 26, 2026 20:27
6b47c80 to
6c8c002
Compare
Contributor
|
Rebased and force-pushed to your branch — your commit (
Verified locally:
Squash-merging once the workflows come back green. Thanks! |
Merged
4 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.
Per-session
projectIdis validated against^prj_[A-Za-z0-9]{16}$(Zod schema intypes.ts), but the client-levelprojectIdwas passed straight to thex-codespar-projectheader with no validation — in both the TS and Python clients. A malformed client-level scope reached the backend instead of failing fast at construction.PROJECT_ID_REGEXintypes.ts(now reused by the Zod schema and theCodeSparconstructor)._PROJECT_ID_REcheck toAsyncCodeSpar.__init__(covers the sync client via its factory).test_session.pythat used 17-char ids (never validated before).Behavior change: a client constructed with a malformed
projectIdnow throws at construction. Tests added (TS + Python).npm test+tsc --noEmitgreen forpackages/core;pytest+mypy+ruffgreen forpackages/python.Note: touches
packages/core/src/index.ts, which also changes in #37 — a trivial merge conflict on the constructor is expected if both land; whichever merges second rebases.