-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(iii-worker): normalize inline empty workers list before append #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+175
−0
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
052a888
test(iii-worker): reproduce invalid YAML after worker add on inline e…
guibeira c6fb686
fix(iii-worker): strip inline `workers: []` marker before appending
guibeira a93750d
fix(iii-worker): preserve trailing comments when normalizing `workers…
guibeira 4cae5d0
fix: yaml file
guibeira 6fd2dc6
fix(iii-worker): address workers yaml review feedback
guibeira 0f91152
Merge branch 'main' into fix/invalid-yaml-after-worker-add
guibeira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restrict normalization scope to the registry
workerskey to avoid config mutation.normalize_empty_workers_listrewrites anyworkers: []line at any indentation depth. Since Line 508 runs it unconditionally before every append, nested user config (e.g., underconfig:) can be silently changed from empty list to null.💡 Suggested patch
fn normalize_empty_workers_list(content: &str) -> String { let lines: Vec<&str> = content.lines().collect(); + // Only normalize the shallowest `workers:` key(s), so nested config keys + // like `config.workers: []` are not rewritten. + let min_workers_indent = lines + .iter() + .filter_map(|line| { + let trimmed = line.trim_start(); + if trimmed.starts_with("workers:") { + Some(line.len() - trimmed.len()) + } else { + None + } + }) + .min(); + let mut out: Vec<String> = Vec::with_capacity(lines.len()); for line in &lines { let trimmed_start = line.trim_start(); - let indent = &line[..line.len() - trimmed_start.len()]; - if let Some(rest) = trimmed_start.strip_prefix("workers:") { + let indent_len = line.len() - trimmed_start.len(); + let indent = &line[..indent_len]; + if Some(indent_len) == min_workers_indent { + if let Some(rest) = trimmed_start.strip_prefix("workers:") { // Split off a trailing comment before checking the marker shape, // so `workers: [] # comment` still matches. let (value, comment) = match rest.find('#') { Some(idx) => (&rest[..idx], Some(&rest[idx..])), None => (rest, None), }; let trimmed = value.trim(); let is_empty_inline_list = trimmed.starts_with('[') && trimmed.ends_with(']') && trimmed.len() >= 2 && trimmed[1..trimmed.len() - 1].trim().is_empty(); if is_empty_inline_list { match comment { Some(c) => out.push(format!("{}workers: {}", indent, c.trim_start())), None => out.push(format!("{}workers:", indent)), } continue; } + } } out.push((*line).to_string()); }Also applies to: 506-509
🤖 Prompt for AI Agents