Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both macOS copies of
read_env_value(installers/macos/lib/env-generator.shandinstallers/macos/ods-macos.sh) return the first matching line of a duplicated.envkey, while the Linux CLI reader (_env_get_rawinods-cli) and every dotenv consumer (docker compose, python-dotenv, the compose stack itself) resolve duplicates last-wins. Same file, different semantics per platform.Why this matters
The backfill guards —
[[ -z "$(read_env_value ... SHIELD_API_KEY)" ]], the Hermes session token check,ODS_SESSION_SECRET,WEBUI_AUTH, GPU limit/reservation reads — all key off this function. A.envcontainingSHIELD_API_KEY=followed bySHIELD_API_KEY=real-key(a common hand-edit artifact: appended key above a previously generated one, or a preserved line above an appended one) reads as empty on macOS, so the installer/CLI regenerates the key andupsert_env_valuerewrites all duplicate lines — silently destroying the operator's real key. On Linux the same file is correctly read asreal-keyand preserved. Aligning to last-wins matches_env_get_raw(tail-equivalent awk loop) and actual dotenv semantics, and makes the "is this key set?" check consistent with what consumers will resolve at runtime.Changes
ods/installers/macos/lib/env-generator.sh—sed -n '1p'→tail -n 1inread_env_valueods/installers/macos/ods-macos.sh— same fix in itsread_env_valuecopyods/tests/test_macos_read_env_value_precedence.py— new regression test exercising both copies: last-duplicate resolution, empty-first/valued-last ordering, missing-key empty read, single-key read, and an end-to-end check that the backfill guard does not fire on a duplicated live keyOverlap check
Searched open/closed PRs for
read_env_value, duplicate env handling, and the touched files:upsert_env_valueliteral-key/delimiter-safe in both copies. Distinct scope: it fixes write-path key matching, not read precedence. No hunk overlap (adjacent functions).env-generator.sh'sread_env_valueon the same line (tr -d '\r'→tr -d '\r"'). Adjacent concern (value sanitization vs duplicate precedence); whichever lands second has a trivial one-line conflict to resolve.ods-support-bundle.sh's separate reader only; does not touch macOS.mode-switch.sh,validate-models.py,bootstrap-upgrade.sh; different files, same defect class.Validation
python3 -m pytest tests/test_macos_read_env_value_precedence.pyon this branch: 4 passed.upstream/public-beta(4d725ee95): 4 failed — base returns the empty first line (expected last duplicate, got:) and the guard fires on a live key (guard fired on a live key), reproducing the clobber path end to end.test_macos_upsert_env_value.py(1 passed),test-macos-direct-bind-bridge.sh,test-macos-installer-transitions.shall pass;test-macos-native-model-store.shskips (requires macOS).tests/test-hermes-dashboard-session-token.pyfails identically on cleanupstream/public-beta— pre-existing stale anchor addressed separately in test(hermes): fix stale Linux anchors in session-token contract test #6173, not a regression from this change.shellcheck -S errorclean on both scripts;bash -nclean;git diff --checkclean.Pending: CI and maintainer review.