fix: initialize task_json in track_iteration_start#152
Open
alilxxey wants to merge 1 commit intoasklokesh:mainfrom
Open
fix: initialize task_json in track_iteration_start#152alilxxey wants to merge 1 commit intoasklokesh:mainfrom
alilxxey wants to merge 1 commit intoasklokesh:mainfrom
Conversation
Under `set -uo pipefail`, `local task_json` without an initializer leaves
the variable unset. When the pending queue is empty (iteration 2+ with no
tasks left), next_task_context is empty, the enrichment `if` block is
skipped, and the subsequent `[[ -z "$task_json" ]]` check crashes with
"unbound variable", killing the run.
Initialize `local task_json=""` at declaration and guard reads with
`${task_json:-}` and `${next_task_context:-}` for defense in depth. Adds
BUG-RUN-003 regression assertions to tests/test-bugfix-audit.sh.
Contributor
|
All contributors have signed the CLA. Thank you. |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
Under
set -uo pipefail,local task_jsonwithout an initializer leaves the variable unset. When the pending queue is empty (iteration 2+ with no tasks left), next_task_context is empty, the enrichmentifblock is skipped, and the subsequent[[ -z "$task_json" ]]check crashes with "unbound variable", killing the run.Initialize
local task_json=""at declaration and guard reads with${task_json:-}and${next_task_context:-}for defense in depth. Adds BUG-RUN-003 regression assertions to tests/test-bugfix-audit.sh.Description
Fixes a crash in
track_iteration_startwherelocal task_jsonwasdeclared without initialization. Under
set -uo pipefail, when thepending queue becomes empty (iteration 2+ after all tasks are done),
next_task_contextis empty, the enrichmentifblock is skipped,and the subsequent
[[ -z "$task_json" ]]check crashes with"unbound variable", killing the run and blocking further iterations.
Reproduction
On v6.75.3 with any PRD:
loki start prd.mdtask_json: unbound variableFix
local task_json=""at declaration (autonomy/run.sh:3602)${task_json:-}/${next_task_context:-}|| task_json=""if the python3 heredoc exits non-zeroAudit
Scanned run.sh for the same anti-pattern (
local varwithout init →conditional
ifassignment → unconditional read). Found 8 candidates;all 7 use
if/elsewith assignment in both branches (safe) and 1 usesif ! var=$(...)which assigns inside the condition (safe).task_jsonwas uniquely vulnerable because it had an
ifwithout anelse.Type of Change
Checklist
bash -n autonomy/run.sh && bash -n autonomy/loki)CLA Acknowledgment
Related Issues
Closes #