Skip to content

fix: use python3 JSON parser in checkLatestRelease() instead of grep#8808

Open
vijaygovindaraja wants to merge 2 commits intomakeplane:previewfrom
vijaygovindaraja:fix/8775-json-parsing-checkLatestRelease
Open

fix: use python3 JSON parser in checkLatestRelease() instead of grep#8808
vijaygovindaraja wants to merge 2 commits intomakeplane:previewfrom
vijaygovindaraja:fix/8775-json-parsing-checkLatestRelease

Conversation

@vijaygovindaraja
Copy link

@vijaygovindaraja vijaygovindaraja commented Mar 27, 2026

Closes #8775

Summary

checkLatestRelease() uses a grep pattern that assumes spaces after colons in GitHub API JSON responses. When GitHub
returns compact/minified JSON, the pattern fails and the install script aborts.

Fix

Replace grep + sed with python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" which handles both
compact and formatted JSON. python3 is already a prerequisite for the Docker setup.

Applied to both:

  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh

Verification

# Old pattern fails on compact JSON
echo '{"tag_name":"v1.2.3"}' | grep -o '"tag_name": "[^"]*"'  # no match

# New pattern works on both formats
echo '{"tag_name":"v1.2.3"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])"  # v1.2.3
echo '{"tag_name": "v1.2.3"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])"  # v1.2.3

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Refactor**
* Improved release-version detection to use JSON parsing for more reliable extraction.
* **Bug Fixes**
* Installer scripts now explicitly require Python 3 and will exit with a clear error if it's not available.
* **Stability**
* Output handling tightened (proper quoting) to avoid unexpected parsing or formatting issues.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

The grep pattern `"tag_name": "[^"]*"` assumes a space after the colon
in the GitHub API JSON response. When GitHub returns compact/minified
JSON without spaces, the pattern fails and the install script aborts
with "Failed to check for the latest release."

Replace grep+sed with python3's json module which handles both compact
and formatted JSON reliably. python3 is already a prerequisite for the
Docker setup scripts.

Applied to both install.sh (CLI) and swarm.sh (Docker Swarm).

Closes makeplane#8775
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Vijay Govindarajan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e461adb-e8ff-4d8b-8f20-33ba99ee0e48

📥 Commits

Reviewing files that changed from the base of the PR and between 8be000c and 1b4d095.

📒 Files selected for processing (2)
  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh

📝 Walkthrough

Walkthrough

Updated two deployment shell scripts to use python3 for parsing GitHub API JSON (tag_name) instead of grep/sed, and to exit with an error if python3 is not available. Quoted echo used for the output.

Changes

Cohort / File(s) Summary
GitHub release parsing
deployments/cli/community/install.sh, deployments/swarm/community/swarm.sh
Replaced grep/sed extraction of "tag_name" with python3 -c 'import sys,json; print(json.load(sys.stdin)[\"tag_name\"])', added a check that python3 is installed, and switched to echo "$latest_release" (properly quoted).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through bytes and JSON bright,

No brittle grep to spoil the night,
Python reads the tag with cheer,
Compact or spaced—no panic here. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing grep-based JSON parsing with Python3 JSON parser in checkLatestRelease().
Description check ✅ Passed The description comprehensively covers the problem, the fix, affected files, and verification steps, matching the template requirements despite not using exact template checkboxes.
Linked Issues check ✅ Passed The code changes fully address the requirements of issue #8775: replacing grep-based extraction with Python3 JSON parsing in both affected files.
Out of Scope Changes check ✅ Passed All changes are scoped to the checkLatestRelease() function across two files and directly address the JSON parsing issue, with no out-of-scope modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 `@deployments/cli/community/install.sh`:
- Line 60: The script currently assumes python3 exists and assigns in one step
which masks command failures; modify the install flow by first checking for
python3 (e.g., test -x "$(command -v python3)" and emit a clear error if
missing) and then split the declaration and assignment for latest_release:
declare local latest_release on its own then assign the output of the
curl|python3 pipeline to it (so failures are visible and SC2155 is avoided).
Apply the identical change to the other occurrence referenced in
deployments/swarm/community/swarm.sh at the line that sets latest_release.
🪄 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: ce46a28b-a5ed-4e81-9321-878153f351e7

📥 Commits

Reviewing files that changed from the base of the PR and between 130ba5e and 8be000c.

📒 Files selected for processing (2)
  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh

- Add explicit `command -v python3` check with clear error message
- Separate `local` declaration from assignment (SC2155)
- Use `-fsSL` curl flags and quote the URL
- Quote `$latest_release` in echo

Addresses review feedback from CodeRabbit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: checkLatestRelease() fails when GitHub API returns compact JSON

2 participants