Repository navigation
fix: replace --json flag with grep for gh pr create compatibility - #4579
Conversation
Summary by CodeRabbit
WalkthroughUpdated PR URL extraction in .github/workflows/prepare-for-prod-ut-deploy.yml: switched from gh CLI JSON/JQ parsing to text-based grep extraction in three PR creation steps (Shared, Hosted, Dedicated). Environment variables (SHARED_PR_URL, HOSTED_PR_URL, DEDICATED_PR_URL) continue to be set. No other logic or control flow changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.github/workflows/prepare-for-prod-ut-deploy.yml (3)
138-140: Harden PR URL extraction: add pipefail, capture stderr, select first match, and guard for empty.The grep approach is fine for broad compatibility, but we can make it more robust and fail-fast if URL extraction doesn’t work (e.g., when gh output format changes, or no PR is created).
Apply this diff within this step:
- PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*') - echo "SHARED_PR_URL=$PR_URL" >> $GITHUB_ENV + PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1) + if [[ -z "$PR_URL" ]]; then + echo "Failed to extract PR URL from gh pr create output" >&2 + exit 1 + fi + echo "SHARED_PR_URL=$PR_URL" >> $GITHUB_ENVAdditionally, at the top of this run block (outside the selected lines), consider enabling pipefail to ensure the step fails if any part of a pipeline fails:
set -o pipefailOptionally, if newer gh is available at runtime, a two-step fallback increases reliability without relying on JSON for the create operation:
# After creation, resolve URL using view (read op) when available; else keep grep result gh pr view --json url -q .url >/dev/null 2>&1 && PR_URL="$(gh pr view --json url -q .url)"
156-158: Repeat the same resilience upgrades for the Hosted PR creation step.Mirroring the shared step makes behavior consistent and prevents silent Slack notifications with empty links if URL extraction fails.
Apply this diff:
- PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*') - echo "HOSTED_PR_URL=$PR_URL" >> $GITHUB_ENV + PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1) + if [[ -z "$PR_URL" ]]; then + echo "Failed to extract PR URL from gh pr create output" >&2 + exit 1 + fi + echo "HOSTED_PR_URL=$PR_URL" >> $GITHUB_ENV
193-195: Apply the same robustness for the Dedicated PR creation step.Keep the extraction logic uniform across all three PR creation sites to simplify future maintenance and debugging.
Apply this diff:
- PR_URL=$(gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*') - echo "DEDICATED_PR_URL=$PR_URL" >> $GITHUB_ENV + PR_URL=$(gh pr create --fill 2>&1 | grep -oE 'https://github\.com/[^/]*/[^/]*/pull/[0-9]+' | head -n1) + if [[ -z "$PR_URL" ]]; then + echo "Failed to extract PR URL from gh pr create output" >&2 + exit 1 + fi + echo "DEDICATED_PR_URL=$PR_URL" >> $GITHUB_ENV
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/prepare-for-prod-ut-deploy.yml(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
|
Allure Test reports for this run are available at:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4579 +/- ##
========================================
Coverage 91.81% 91.81%
========================================
Files 642 642
Lines 33930 33930
Branches 8041 8031 -10
========================================
Hits 31152 31152
- Misses 2526 2548 +22
+ Partials 252 230 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



What are the changes introduced in this PR?
Fixed GitHub CLI compatibility issue in the prepare-for-prod-ut-deploy.yml workflow by replacing the --json flag with grep for extracting PR URLs.
What is the related Linear task?
N/A - Bug fix for workflow compatibility
Please explain the objectives of your changes below
The --json flag is not available for write operations like gh pr create in older versions of GitHub CLI, causing workflow failures. This fix ensures compatibility across different GitHub CLI versions.
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
Change: Replaced gh pr create --fill --json url --jq '.url' with gh pr create --fill | grep -o 'https://github.com/[^/]*/[^/]*/pull/[0-9]*'
Reason: The --json flag is only available for read operations (like gh release view) but not for write operations (like gh pr create) in older GitHub CLI versions.
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
The new approach uses grep with regex to extract PR URLs, which is more compatible but slightly less robust than JSON parsing. However, it works reliably for GitHub PR URLs.
@coderabbitai review