Skip to content

fix: match double-quoted __version__ in .ci/update_version - #7754

Open
eran132 wants to merge 1 commit into
getredash:masterfrom
eran132:fix/update-version-regex
Open

eran132 wants to merge 1 commit into
getredash:masterfrom
eran132:fix/update-version-regex

Conversation

@eran132

@eran132 eran132 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What & why

Fixes #7598.

.ci/update_version stamps the build version into redash/__init__.py during release CI:

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py

The pattern matches a single-quoted value, but the file declares the version with double quotes:

__version__ = "26.06.0-dev"

So the substitution never matches and the version is silently left as the -dev placeholder in built images — FULL_VERSION (<version>+b<run_id>.<run_number>) is never applied.

Fix

One line — match (and emit) the double-quoted form.

Testing

Verified end-to-end by running the actual script against temp copies with CI-like env (GITHUB_RUN_ID/GITHUB_RUN_NUMBER/GITHUB_SHA, real package.json version via jq):

  • Old script: __version__ left unchanged — reproduces the bug.
  • New script: __version__ becomes 26.06.0-dev+b12345.67; exactly one line changes; the client/app/version.json dev → SHA step is unaffected.

5/5 assertions pass.

Review in cubic

The release version-stamping sed matched `__version__ = '...'` (single
quotes), but redash/__init__.py declares `__version__ = "26.06.0-dev"` with
double quotes, so the substitution never matched and CI builds were never
stamped with the run's FULL_VERSION. Update the pattern (and replacement) to
use double quotes.

Fixes getredash#7598
Copilot AI review requested due to automatic review settings June 15, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the CI version-bumping script to rewrite redash/__init__.py’s __version__ assignment using double quotes.

Changes:

  • Adjusted the sed match/replace pattern for __version__ to target double-quoted values.
  • Kept the build metadata formatting (+b<run_id>.<run_number>) in FULL_VERSION.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .ci/update_version
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
Comment thread .ci/update_version
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".ci/update_version">

<violation number="1" location=".ci/update_version:5">
P2: Post-substitution verification is missing: sed returns success (0) even when no replacements are performed, so format drift in `redash/__init__.py` will again silently leave the version unstamped.</violation>

<violation number="2" location=".ci/update_version:5">
P2: This sed pattern is now hard-coded to double quotes. If the quote style in `redash/__init__.py` ever changes (e.g., a formatter switches to single quotes), the substitution will silently fail again — the same class of bug this PR fixes. Consider matching either quote style (e.g., `["']`) and reusing the captured quote in the replacement to make this resilient to formatting changes.</violation>

<violation number="3" location=".ci/update_version:5">
P2: The character class `[A-Za-z0-9.-]` does not include `+`, but `FULL_VERSION` contains `+` (e.g., `26.06.0-dev+b12345.67`). If this script runs against a file that already has a stamped version with build metadata, the regex won't match and the substitution will silently do nothing. Add `+` to the character class (or match everything up to the closing quote) to make the script idempotent.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .ci/update_version
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Post-substitution verification is missing: sed returns success (0) even when no replacements are performed, so format drift in redash/__init__.py will again silently leave the version unstamped.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .ci/update_version, line 5:

<comment>Post-substitution verification is missing: sed returns success (0) even when no replacements are performed, so format drift in `redash/__init__.py` will again silently leave the version unstamped.</comment>

<file context>
@@ -2,5 +2,5 @@
 FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}
 
-sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
+sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
 sed -i "s/dev/${GITHUB_SHA}/" client/app/version.json
</file context>
Suggested change
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
grep -qF "__version__ = \"${FULL_VERSION}\"" redash/__init__.py || { echo "ERROR: Failed to stamp version"; exit 1; }

Comment thread .ci/update_version
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This sed pattern is now hard-coded to double quotes. If the quote style in redash/__init__.py ever changes (e.g., a formatter switches to single quotes), the substitution will silently fail again — the same class of bug this PR fixes. Consider matching either quote style (e.g., ["']) and reusing the captured quote in the replacement to make this resilient to formatting changes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .ci/update_version, line 5:

<comment>This sed pattern is now hard-coded to double quotes. If the quote style in `redash/__init__.py` ever changes (e.g., a formatter switches to single quotes), the substitution will silently fail again — the same class of bug this PR fixes. Consider matching either quote style (e.g., `["']`) and reusing the captured quote in the replacement to make this resilient to formatting changes.</comment>

<file context>
@@ -2,5 +2,5 @@
 FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}
 
-sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
+sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
 sed -i "s/dev/${GITHUB_SHA}/" client/app/version.json
</file context>

Comment thread .ci/update_version
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The character class [A-Za-z0-9.-] does not include +, but FULL_VERSION contains + (e.g., 26.06.0-dev+b12345.67). If this script runs against a file that already has a stamped version with build metadata, the regex won't match and the substitution will silently do nothing. Add + to the character class (or match everything up to the closing quote) to make the script idempotent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .ci/update_version, line 5:

<comment>The character class `[A-Za-z0-9.-]` does not include `+`, but `FULL_VERSION` contains `+` (e.g., `26.06.0-dev+b12345.67`). If this script runs against a file that already has a stamped version with build metadata, the regex won't match and the substitution will silently do nothing. Add `+` to the character class (or match everything up to the closing quote) to make the script idempotent.</comment>

<file context>
@@ -2,5 +2,5 @@
 FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}
 
-sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
+sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
 sed -i "s/dev/${GITHUB_SHA}/" client/app/version.json
</file context>
Suggested change
sed -ri "s/^__version__ = \"([A-Za-z0-9.-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py
sed -ri "s/^__version__ = \"([A-Za-z0-9.+-]*)\"/__version__ = \"${FULL_VERSION}\"/" redash/__init__.py

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.

.ci/update_version regular expression is broken

2 participants