ci: add versioning for node-sdk genarator#2913
Conversation
π WalkthroughWalkthroughUpdated GitHub Actions workflow configuration in Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~8 minutes Possibly related PRs
Poem
π₯ Pre-merge checks | β 5β Passed checks (5 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/sdk-generator.yml:
- Line 64: The workflow currently injects the raw version into a JSON string at
the inputs line ('inputs: '{ "version": "${{ github.event.release.tag_name ||
inputs.version }}" }'') which can break if the version contains
quotes/backslashes; change it to emit a proper JSON object using GitHub Actions
JSON-escaping (use toJSON/toJson) so the version is escaped, e.g. replace that
line with an expression that constructs the object and calls toJSON: ${{
toJSON({ version: github.event.release.tag_name || inputs.version }) }},
ensuring the forwarded version value is safely JSON-escaped.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4c603d33-93ce-48d6-a6f3-99a5269b150c
π Files selected for processing (1)
.github/workflows/sdk-generator.yml
| repo: Permify/permify-node | ||
| ref: main | ||
| token: "${{ secrets.SDK_GH_TOKEN }}" | ||
| inputs: '{ "version": "${{ github.event.release.tag_name || inputs.version }}" }' |
There was a problem hiding this comment.
π§© Analysis chain
π Script executed:
#!/bin/bash
# Description: Demonstrate why direct interpolation into JSON is brittle.
python - <<'PY'
import json
versions = [
"v1.6.9",
'v1.6.9"bad',
r"v1.6.9\bad",
]
for version in versions:
current = '{ "version": "' + version + '" }'
escaped = '{ "version": ' + json.dumps(version) + " }"
print(f"\nversion={version!r}")
try:
parsed = json.loads(current)
print("current parses:", parsed)
except json.JSONDecodeError as exc:
print("current fails:", exc)
parsed = json.loads(escaped)
print("escaped parses:", parsed)
PYRepository: Permify/permify
Length of output: 393
π Script executed:
cd /tmp && find . -name "sdk-generator.yml" -type f 2>/dev/null | head -5Repository: Permify/permify
Length of output: 41
π Script executed:
head -n 80 .github/workflows/sdk-generator.ymlRepository: Permify/permify
Length of output: 2627
π Script executed:
if [ -f ".github/workflows/sdk-generator.yml" ]; then
wc -l .github/workflows/sdk-generator.yml
sed -n '55,75p' .github/workflows/sdk-generator.yml
else
echo "File not found"
ls -la .github/workflows/ 2>/dev/null || echo "Directory not found"
fiRepository: Permify/permify
Length of output: 599
π Web query:
GitHub Actions toJson format function documentation
π‘ Result:
The toJSON function in GitHub Actions is part of the expression syntax used to convert objects, arrays, or other values into a pretty-printed JSON string representation. It is primarily used for debugging purposes, such as logging context information. Syntax: toJSON(value) Description: Returns a pretty-print JSON representation of the provided value. Commonly used with contexts like github, job, steps, runner, etc. Example from official documentation: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJSON(github) }} run: echo "$GITHUB_CONTEXT" This outputs the entire github context as formatted JSON to the log. Note the warning: the github context includes sensitive data like github.token, which GitHub masks in logs, but caution is advised when exporting. toJSON(job) might return { "status": "success" }. It pairs with fromJSON(value), which parses a JSON string back into an object or primitive type. Official documentation is in the "Evaluate expressions in workflows and actions" page, with usage examples in "Contexts reference".
Citations:
- 1: https://docs.github.com/en/enterprise-cloud@latest/actions/reference/workflows-and-actions/expressions
- 2: https://docs.github.com/en/actions/reference/workflows-and-actions/expressions
- 3: https://docs.github.com/actions/reference/workflows-and-actions/expressions
- 4: https://docs.github.com/en/actions/learn-github-actions/expressions
- 5: https://docs.github.com/en/actions/reference/workflows-and-actions/contexts
- 6: https://docs.github.com/en/actions/reference/contexts-reference
π Web query:
benc-uk workflow-dispatch inputs parameter how to pass JSON
π‘ Result:
To pass JSON as inputs parameters to a workflow_dispatch using the benc-uk/workflow-dispatch GitHub Action, provide a JSON-encoded string to the inputs parameter. The inputs input must be a valid JSON string containing key-value pairs that match the target workflow's workflow_dispatch.inputs definition. Example usage in a GitHub Actions workflow: - name: Trigger workflow with JSON inputs uses: benc-uk/workflow-dispatch@v2 with: workflow: "Target Workflow" token: ${{ secrets.MY_TOKEN }} inputs: '{ "message": "Hello world", "debug": true, "config": {"key": "value"} }' Key points: - All values in the JSON must be strings, even for booleans/numbers in the target workflow (use fromJson(inputs.myInput) in the target to parse). - For complex/nested JSON, use jq -c to compact it into a single-line string to avoid YAML multiline issues. - Recent updates (v1.3.1, Feb 2026) include safer JSON parsing that logs errors instead of crashing. - Requires a Personal Access Token (PAT) with repo scope for cross-repo triggers. In the target workflow, access via ${{ inputs.message }} or ${{ fromJson(inputs.config).key }}. Official documentation: https://github.com/benc-uk/workflow-dispatch
Citations:
- 1: https://github.com/benc-uk/workflow-dispatch
- 2: benc-uk/workflow-dispatch@7a02764
- 3: https://github.com/the-actions-org/workflow-dispatch
π Web query:
GitHub Actions format() toJSON() expression functions available
π‘ Result:
Yes, both format and toJSON are available expression functions in GitHub Actions. format(string, replaceValue0, replaceValue1, ..., replaceValueN): Replaces values in the string using {N} placeholders. Escape curly braces with double braces. Example: format('Hello {0} {1}', 'Mona', 'Octocat') returns 'Hello Mona Octocat'. toJSON(value): Returns a pretty-printed JSON representation of the value, useful for debugging contexts. Example: toJSON(github) or toJSON(job). These are documented in the official GitHub Actions expressions reference and remain current as of 2026.
Citations:
- 1: https://docs.github.com/actions/reference/workflows-and-actions/expressions
- 2: https://docs.github.com/en/actions/learn-github-actions/expressions
- 3: https://docs.github.com/en/actions/reference/workflows-and-actions/expressions
- 4: https://docs.github.com/en/enterprise-cloud@latest/actions/reference/workflows-and-actions/expressions
JSON-escape the forwarded version value.
Line 64 interpolates user input directly into JSON. A version value containing quotes or backslashes can produce invalid JSON or corrupt the forwarded value.
Proposed fix
- inputs: '{ "version": "${{ github.event.release.tag_name || inputs.version }}" }'
+ inputs: >-
+ ${{ format('{{ "version": {0} }}', toJson(github.event.release.tag_name || inputs.version)) }}π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| inputs: '{ "version": "${{ github.event.release.tag_name || inputs.version }}" }' | |
| inputs: >- | |
| ${{ format('{{ "version": {0} }}', toJson(github.event.release.tag_name || inputs.version)) }} |
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/sdk-generator.yml at line 64, The workflow currently
injects the raw version into a JSON string at the inputs line ('inputs: '{
"version": "${{ github.event.release.tag_name || inputs.version }}" }'') which
can break if the version contains quotes/backslashes; change it to emit a proper
JSON object using GitHub Actions JSON-escaping (use toJSON/toJson) so the
version is escaped, e.g. replace that line with an expression that constructs
the object and calls toJSON: ${{ toJSON({ version: github.event.release.tag_name
|| inputs.version }) }}, ensuring the forwarded version value is safely
JSON-escaped.
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2913 +/- ##
=======================================
Coverage 81.98% 81.98%
=======================================
Files 74 74
Lines 11215 11215
=======================================
Hits 9193 9193
Misses 1486 1486
Partials 536 536 β View full report in Codecov by Sentry. π New features to boost your workflow:
|
Summary by CodeRabbit