Skip to content

Fix is_newer_version() aborting on non-numeric version segments - #6519

Open
Adityaj0 wants to merge 1 commit into
aws:mainfrom
Adityaj0:fix/is-newer-version-nonnumeric-segments
Open

Adityaj0 wants to merge 1 commit into
aws:mainfrom
Adityaj0:fix/is-newer-version-nonnumeric-segments

Conversation

@Adityaj0

Copy link
Copy Markdown

Note on CONTRIBUTING.md: I am aware this repo currently states it is not accepting external contributions. This PR is offered only as a ready-made patch for #6516 — please close it without review if that is the standing policy, and treat the issue as the real report. No offence taken.

Purpose

Fixes #6516.

is_newer_version() in scripts/ci/autocurrency/utils.sh pushed every version segment through bash base-10 arithmetic. A segment like 13+dlc1 makes bash parse 10#13 + dlc1 and try to resolve dlc1 as a variable, which aborts under the set -u that utils.sh sets at the top:

$ bash -c 'source scripts/ci/autocurrency/utils.sh; is_newer_version "0.5.14" "0.5.13+dlc1"'
scripts/ci/autocurrency/utils.sh: line 82: dlc1: unbound variable

check-upstream-releases.sh runs each framework inside a set -euo pipefail subshell, so this kills that framework's entire update block and surfaces only ::warning::sglang: Processing failed with exit code 1.

The +dlc<n> suffix is a live convention here — documented in check_framework_version_currency.py as framework_version == "<upstream_release>[+dlc<n>]", and present today in sglang/ec2-amzn2023.yml and sglang/sagemaker-amzn2023.yml as 0.5.14+dlc1. The tracked config_files[0] entries are plain numeric right now, so the nightly job survives on luck; a config reorder or a +dlc rebuild on a tracked config breaks it.

Separately, the loop was fixed at for i in 0 1 2, so 1.0.0.1 compared equal to 1.0.0 and no update PR would ever be raised.

Changes:

  • New release_segments() keeps the leading digits of each segment and stops at the first suffix, so +dlc1, .post1 and .dev361 never reach the arithmetic.
  • Compare across every segment present, padding the shorter side with zeros.
  • Malformed input returns 2 with a stderr message instead of aborting. Callers use if ! is_newer_version ..., so that reads as "not newer" and skips — the safe direction.

Test Plan

New scripts/ci/autocurrency/utils_test.sh — plain bash, no dependencies, runnable directly:

./scripts/ci/autocurrency/utils_test.sh

25 assertions covering both regressions plus the existing numeric, padding and leading-zero behaviour. There was no shell unit-test harness under scripts/ci/, so this adds a minimal one rather than pulling in bats.

Lint/format checks run on the changed files:

bash -n scripts/ci/autocurrency/utils.sh scripts/ci/autocurrency/utils_test.sh

Test Result

$ ./scripts/ci/autocurrency/utils_test.sh
release_segments: strips local and suffix segments
  ok   release_segments('0.5.13+dlc1') == '0 5 13'
  ok   release_segments('0.17.0.post1') == '0 17 0'
  ...
is_newer_version: local version segments (regression)
  ok   +dlc suffix on current does not abort
  ok   +dlc rebuild is not behind its own release
is_newer_version: segments beyond the third (regression)
  ok   fourth segment is not truncated away
...
============================================================
Passed: 25  Failed: 0

Against the pre-fix implementation the suite aborts on the first +dlc1 assertion, confirming these are genuine regression tests rather than tests written to pass.

Behaviour table:

case before after
is_newer_version 0.5.14 0.5.13+dlc1 aborts (unbound variable) 0 — newer
is_newer_version 0.5.13 0.5.13+dlc1 aborts 1 — not newer
is_newer_version 1.0.0.1 1.0.0 1 — not newer (wrong) 0 — newer
is_newer_version 0.17.0 0.16.0 0 — newer 0 — newer
is_newer_version notaversion 0.17.0 0 — newer (wrong) 2 + stderr

bash -n passes on both shell files.


Toggle if you are merging into main Branch

PR Checklist

  • I ran pre-commit run --all-files locally before creating this PR.

Not fully run — disclosing rather than checking the box. pre-commit could not install its hook environments in my sandbox (URLError: CERTIFICATE_VERIFY_FAILED fetching the hook repos). What I ran instead, directly:

  • bash -n on both changed shell files — pass

Not run, and worth a maintainer's eye on CI: shfmt (the formatting hook that applies to these files), typos, gitleaks. I matched the existing 2-space indentation and comment-banner style of utils.sh, but shfmt has not verified that.

is_newer_version() pushed every version segment through bash base-10
arithmetic. A segment like "13+dlc1" made bash resolve `dlc1` as an
identifier, which aborts the script under `set -u`:

    $ is_newer_version "0.5.14" "0.5.13+dlc1"
    utils.sh: line 82: dlc1: unbound variable

check-upstream-releases.sh runs each framework in a `set -euo pipefail`
subshell, so this killed the framework's whole update block and reported
only a bare exit code. The `+dlc<n>` suffix is a live convention here —
sglang/ec2-amzn2023.yml and sglang/sagemaker-amzn2023.yml carry
0.5.14+dlc1 today — so the nightly tracker was one config reorder away
from breaking. Without `set -u` the failure is quieter and worse: bash
resolves the unknown identifier to 0 and the comparison is silently wrong.

The comparison also stopped after three segments, so a four-segment
upstream release read as identical to its predecessor and never raised
an update PR.

Extract release_segments(), which keeps the leading digits of each
segment and stops at the first suffix, so "+dlc1", ".post1" and ".dev361"
no longer reach the arithmetic. Compare across every segment present,
padding the shorter side. Malformed input now returns 2 with a message
on stderr instead of aborting; callers testing `if ! is_newer_version`
treat that as "not newer" and skip, which is the safe direction.

Add utils_test.sh, a dependency-free bash runner covering the two
regressions plus the existing numeric, padding and leading-zero
behavior. It aborts on the first assertion against the old
implementation.

Closes aws#6516

Signed-off-by: Aditya Jain <adityaj0@uci.edu>
@Adityaj0

Copy link
Copy Markdown
Author

@sallyseok can you review this?

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked stale due to 30 days of inactivity. Please comment or remove the stale label to keep it open. It will be closed in 5 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autocurrency: is_newer_version() aborts on non-numeric version segments (e.g. 0.5.13+dlc1)

1 participant