fix: CLI compose hash 0x prefix in --prepare-only#220
Merged
Leechael merged 1 commit intofeat/two-phase-deploy-multisigfrom Mar 22, 2026
Merged
fix: CLI compose hash 0x prefix in --prepare-only#220Leechael merged 1 commit intofeat/two-phase-deploy-multisigfrom
Leechael merged 1 commit intofeat/two-phase-deploy-multisigfrom
Conversation
Compose hash is now displayed as 0x-prefixed hex in both human-readable and JSON output for direct copy-paste compatibility.
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/23396309890 |
Comment on lines
+1040
to
+1042
| const composeHashHex = result.composeHash.startsWith("0x") | ||
| ? result.composeHash | ||
| : `0x${result.composeHash}`; |
There was a problem hiding this comment.
Bug: A missing null check on result.composeHash can cause a runtime crash when the --prepare-only flag is used and the API response lacks the compose_hash field.
Severity: MEDIUM
Suggested Fix
Add a null/undefined check for result.composeHash before calling .startsWith() on it. For a more robust fix, use the existing Zod schema to validate the error response during its construction in patch_cvm.ts to ensure composeHash is always present as expected.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: cli/src/commands/deploy/handler.ts#L1040-L1042
Potential issue: When using the `--prepare-only` flag, the code at `handler.ts:1040`
calls `.startsWith()` on `result.composeHash`. This value originates from an API error
response and is cast to a string using `as string` without proper validation. If the
backend returns a 465 error without a `compose_hash` field in its response body,
`result.composeHash` will be `undefined` at runtime. This will cause the CLI to crash
with a `TypeError: Cannot read property 'startsWith' of undefined`.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Compose hash is now displayed as 0x-prefixed hex for direct copy-paste.