fix: safe generated identifiers and argv-based command execution - #180
Merged
Conversation
- reject operations whose camel-cased names collide - escape reserved words in generated method and binding names - avoid binding renames in type positions - replace string-interpolated shell commands with execFileSync/fs moves
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Three unrelated correctness fixes in codegen output and CLI command execution.
1. Ambiguous operation names now fail fast.
transfer_nftandtransferNftare distinct wire operations that bothcamel()-normalize totransferNft, so client/composer/builder/react-query/recoil each emitted two declarations with the same name (invalid TS, or one silently shadowing the other).getMessagePropertiesnow detects this and throws:2. Reserved words no longer leak into generated identifiers. New
packages/ast/src/utils/names.ts:All generator surfaces (client, message-composer, message-builder, recoil, react-query) use
camelMethodNamefor member names andcamelVarName/varNamefor destructuring bindings. Wire keys are unchanged — only the TS-side identifier is renamed:createTypedObjectParamsgained aninTypeflag: binding renames ({ class: _class }) are illegal in a TS function type position, so interface signatures fall back to a plainparams: { class: string; ... }parameter when any key needs escaping.3. Commands are executed with an argv array instead of a shell string.
install.tsbuiltexec(\mv ${src} ${dst}`)wheredstis cwd-derived, andnpm install ${pkgs} ...;create-boilerplate.tsbuiltgit clone ${repo} ${name}` from a prompt value. Paths/names containing shell metacharacters were interpreted by the shell. Now:New tests in
packages/ast/__tests__/utils/safe-names.test.tscover the helpers, the collision error, and snapshots of generated output for aconstructoroperation withclass/default/deletepayload properties. All existing snapshots are unchanged except the one client binding line that now readsthis._constructor = this._constructor.bind(this).Link to Devin session: https://app.devin.ai/sessions/bb89d57636c84c7383305191a303b1d4
Open in Devin Desktop: https://app.devin.ai/desktop/session/bb89d57636c84c7383305191a303b1d4?variant=devin
Requested by: @pyramation