Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/sdk-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name: Generate Client SDKs from OpenAPI
on:
release:
types: [published]
workflow_dispatch:
workflow_dispatch:
inputs:
version:
description: "Optional release tag to forward to SDK workflows that need explicit versioning, for example v1.6.9"
required: false
type: string

jobs:
build:
Expand Down Expand Up @@ -56,3 +61,4 @@ jobs:
repo: Permify/permify-node
ref: main
token: "${{ secrets.SDK_GH_TOKEN }}"
inputs: '{ "version": "${{ github.event.release.tag_name || inputs.version }}" }'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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)
PY

Repository: Permify/permify

Length of output: 393


🏁 Script executed:

cd /tmp && find . -name "sdk-generator.yml" -type f 2>/dev/null | head -5

Repository: Permify/permify

Length of output: 41


🏁 Script executed:

head -n 80 .github/workflows/sdk-generator.yml

Repository: 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"
fi

Repository: 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:


🌐 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:


🌐 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:


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.

Suggested change
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.

Loading