fix(js): correct kms_info.chain_id type in app attestation schema#445
Open
Leechael wants to merge 1 commit into
Open
fix(js): correct kms_info.chain_id type in app attestation schema#445Leechael wants to merge 1 commit into
Leechael wants to merge 1 commit into
Conversation
Contributor
📋 Check Results✨ JS SDK - Code FormattingShow format check results🔍 JS SDK - TypeScript Type CheckShow type check output🧪 JS SDK - Test ResultsShow test output📝 JS SDK - Lint CheckShow lint results🌐 JS SDK - Browser CompatibilityShow browser test results🌐 Browser Compatibility ReportBrowser compatibility tests completed across:
The SDK has been verified to work in modern browser environments. Check run: https://github.com/Phala-Network/phala-cloud/actions/runs/27080637650 |
chain_id in the /apps/{appId}/attestations response is serialized as an
integer (or null) by the backend, not a string. The schema declared it as
z.string().nullable() since the action was first added, which only passed
validation for legacy/PHALA-KMS apps where chain_id is null. On-chain KMS
apps return a numeric chain_id and tripped a zod invalid_type error on the
TCB evaluation page.
d2b00a0 to
f11735e
Compare
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.
Problem
The TCB evaluation page (
/{workspace}/apps/{app_id}/attestations/tcb-evaluation) throws a zodinvalid_typeerror:Root cause
KmsInfoSchema.chain_idinget_app_attestation.tshas beenz.string().nullable()since the action was first added (commit 4d534e9), but the backendGET /apps/{appId}/attestationsendpoint serializeschain_idas an integer or null (_normalize_kms_chain_id(value: int | None) -> int | None, DB columnMapped[Optional[int]]).The bug stayed hidden because legacy / PHALA-KMS apps serialize
chain_idasnull(whichz.string().nullable()accepts). Only on-chain KMS apps return a numericchain_idand trip the validation.Fix
Change
chain_idtoz.number().nullable(), matching the backend. Every otherchain_idschema in the codebase is alreadyz.number().Test
bun run fmt && bun run lint && bun run type-check && bun run test— all pass (725 tests).