Repository navigation
Fix config-remote-sync failing on YAML anchors - #7950
ilyakuz-db wants to merge 2 commits into
Conversation
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at ad1c97e. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR makes config-remote-sync keep YAML anchors valid when it writes remote changes back. Before each patch, aliases on the changed path are expanded, and anchors on edited or removed nodes are handed to their next alias, so the unknown anchor failure on re-parse goes away. The main path holds up when traced through the patcher and the parent-path retry. One gap: the null-ancestor fallback still runs on the un-isolated content, so adds through an aliased or anchored null parent still fail. There is also no test for the retry path, and the changelog fragment and the acceptance script's jq usage need small fixes.
Comments outside the changed lines
- [nice to have]
.nextchanges/bundles:bundle config-remote-sync --saveused to fail withunknown anchor 'name' referencedon files with anchors. It now writes the file, and it rewrites aliases that receive an edit into inline copies. Users can see both, and the PR adds no fragment. Can you add an entry under.nextchanges/bundles/, or say why this experimental command doesn't need one?
| return nil, fmt.Errorf("failed to parse JSON Pointer %s: %w", jsonPointer, err) | ||
| } | ||
|
|
||
| source, err := isolateAnchors(content, fieldPathCandidate, fieldChange.Change.Operation) |
There was a problem hiding this comment.
[nice to have] The isolated source goes to the patcher and the parent-path retry, but the fallback at line 151 still calls addThroughNullAncestor(content, ...) on the original content. That function bails on any anchored ancestor (line 215), and yamlChild can't follow an AliasNode. So other: &shared null\nparent: *shared with an add at parent.key still fails with scalar can not be a container, and so does parent: &shared {tags: null}\nother: *shared at parent.tags.key, even though after isolation both are plain nulls the fallback could fill in. Could the fallback run on the isolated source for each candidate? Then the anchor guard in addThroughNullAncestor could go, and those TestApplyChangeScalarParents cases would show the fix instead of pinning the error.
|
|
||
| patcher := gopkgv3yamlpatcher.New(gopkgv3yamlpatcher.IndentSpaces(2)) | ||
| modifiedContent, patchErr := patcher.Apply(content, yamlpatch.Patch{yamlpatch.Operation{ | ||
| modifiedContent, patchErr := patcher.Apply(errInfo.source, yamlpatch.Patch{yamlpatch.Operation{ |
There was a problem hiding this comment.
[nice to have] Switching this retry from content to errInfo.source is part of the fix, but none of the TestApplyChangeKeepsAnchors cases reach it. For example, a: &x\n k: 1\nb: *x\n with an add at b.m.n fails first with a missing /b/m parent, so it goes through this retry. Can you add that case and assert that a stays {k: 1} and only b gains m: {n: 2}?
| rm databricks.yml.backup | ||
|
|
||
| title "Only the changed tasks differ" | ||
| trace $CLI bundle validate -o json | jq -c '.resources.jobs.my_job.tasks[] | {task_key, job_cluster_key, libraries}' |
There was a problem hiding this comment.
[nit] .agents/rules/testing.md asks for the acceptance/bin/ helpers instead of inline jq pipelines. Could this use gron.py | grep on the task fields (task_key, job_cluster_key, libraries) instead of the hand-written jq -c projection?
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 2 tests: regression=2 unreleased=0 coverage=0 failing=0
TestAccept/bundle/config-remote-sync/yaml_anchors/DMS=: branch ✅ | main (c639f9d) ❌ | latest (v1.28.0) ❌main (c639f9d): latest (v1.28.0): same output as main (c639f9d) TestAccept/bundle/config-remote-sync/yaml_anchors/DMS=true: branch ✅ | main (c639f9d) ❌ | latest (v1.28.0) ❌main (c639f9d): latest (v1.28.0): same output as main (c639f9d) |
✅ Integration test reportCommit: ad1c97e
Top 6 slowest tests (at least 2 minutes):
|
Changes
config-remote-synckeeps YAML anchors working when it writes remote changes back. Before each patch, an alias on the changed path is expanded into a copy, and an anchored node that the change edits or removes hands its anchor to its first other alias, so the aliases after it still resolve.Why
When a remote change removed or replaced a node holding an anchor (
&name), the aliases (*name) elsewhere in the file were left dangling, and the next re-parse failed withunknown anchor 'name' referenced. An edit through an alias also went into the shared anchor and changed every alias.An edit to an aliased field now changes only that field: its alias becomes an inline copy, so a file where every alias gets the same remote edit ends up with copies instead of one shared anchor. Fields inherited through merge keys (
<<: *base) are out of scope here.Tests
New unit cases in
bundle/configsync/patch_test.goand aconfig-remote-sync/yaml_anchorsacceptance test, which reproduced the error on main. Both pass locally, and lint is clean.ad1c97e(latest)ad1c97e(latest)RIGHT-SIZED: adds the anchor bookkeeping the patcher lacks, right before it runsad1c97e(latest)ad1c97e(latest)ad1c97e(latest)ad1c97e(latest)✅ success · ⏳ pending ·⚠️ warning · ❌ failed · ➖ n/a