Repository navigation
Conversation
Managed-mode writeback can emit TOML that Komodo itself cannot parse, which
leaves the sync permanently broken until a human edits the file.
replace_resource_target_ids! rewrote each id to the resource name and fell
back to unwrap_or_default() when the lookup missed, so a miss produced an
empty String. ResourceTarget is adjacently tagged (tag = "type", content =
"id"), and TOML_PRETTY_OPTIONS sets skip_empty_string, so the empty id is
dropped from the emitted table. The result is
resources = [{ type = "Stack" }]
which cannot be deserialized back into a ResourceTarget, so every later read
of that file fails with 'missing field id'.
Leaving the id untouched on a miss keeps the value round-trippable. Nothing
else changes: the only behavioural difference is what happens on a miss, and
the previous outcome on a miss was an unparseable file.
This branch has not been deployed
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.
Managed-mode writeback can emit TOML that Komodo itself cannot parse, which leaves the sync broken until someone edits the file by hand. Hit this on a live deployment; the deploy pipeline stopped until I removed the offending line.
What happens
A
Commit Syncwrote this intoresources.toml:Every read after that failed:
Why
replace_resource_target_ids!rewrote each id to the resource name with.map(|r| r.name.clone()).unwrap_or_default(), so a missed lookup yields an emptyString.ResourceTargetis adjacently tagged,#[serde(tag = "type", content = "id")], soidis required to deserialize.TOML_PRETTY_OPTIONSsetsskip_empty_string: true, so the emptyidis omitted from the emitted table.In my case the lookup missed because the file supplied the target by name, which is how every other synced reference is written, while the cache is keyed by id. Whether names should be accepted in that position is a separate question; this PR only stops a miss from corrupting the file.
The change
Leave the id untouched when the lookup misses. On a hit nothing changes; on a miss the previous outcome was a file that cannot be read back.
DeploymentImage::Buildhas the same shape (build_idblanked, adjacently tagged) and is covered in #1584. The plainStringfields nearby (server_id,swarm_id,linked_repo,builder_id) still parse when empty, so they are unaffected.Verification
cargo check -p komodo_coreclean with no new warnings,cargo fmt --checkclean. No test: the macro reads the globalall_resources_cache()andbin/corehas no test scaffolding for it.