Repository navigation
[factory:bug-fixer][custom-training] Report all convert-to-dabs output conflicts before writing (CNXT-2665) - #7859
ben-hansen-db wants to merge 6 commits into
Conversation
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/air/convert-to-dabs: branch ✅ | main (c639f9d) ❌ | latest (v1.28.0) ❌main (c639f9d): latest (v1.28.0): same output as main (c639f9d) |
There was a problem hiding this comment.
Automated review at 6e9ea5e. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR adds a preflight pass (checkBundleOutputPaths) that detects all conflicting output paths before writing any files during air convert-to-dabs, fixing a real bug where a partial bundle could be left behind. The approach is sound, but the test file uses syscall.ELOOP, which is undefined on Windows and will break compilation there. The write paths after the preflight should unconditionally overwrite (as the base code did for SaveAsYAML) to avoid inconsistent error messages in a narrow TOCTOU race.
| "path/filepath" | ||
| "runtime" | ||
| "slices" | ||
| "strings" |
There was a problem hiding this comment.
[blocking] syscall.ELOOP is not defined on Windows. Because the import and usage (line 244) live in a file with no build constraint, the entire test file fails to compile on GOOS=windows. The runtime.GOOS == "windows" / t.Skip guard at line 221 is a runtime check and never runs when the build itself is broken. Move TestConvertToDabsPreflightsSymlinkLookupErrors and the "syscall" import into a _unix_test.go file behind //go:build !windows, or replace syscall.ELOOP with a platform-neutral check (e.g. assert the error string contains the path without asserting the errno).
There was a problem hiding this comment.
Go 1.27.4 declares syscall.ELOOP on Windows. I cross-compiled var _ error = syscall.ELOOP for windows/amd64 with the pinned toolchain, so the test can keep its errors.Is assertion. Go 1.27.4 Windows errno definitions
| // above already decided whether overwriting is allowed. | ||
| if err := yamlsaver.NewSaver().SaveAsYAML(root, bundlePath, true); err != nil { | ||
| bundlePath := filepath.Join(dir, bundleFileName) | ||
| if err := yamlsaver.NewSaver().SaveAsYAML(root, bundlePath, force); err != nil { |
There was a problem hiding this comment.
[nice to have] The base code passed true to SaveAsYAML with an explicit comment: "the collision check above already decided whether overwriting is allowed." The new preflight serves the same role, but now the raw force flag is passed. If force=false and a file races in between the preflight and this call, SaveAsYAML (saver.go:42) produces "<path> already exists. Use --force to overwrite" — different wording and format from the unified preflight message. The same pattern applies at line 724: filer.LocalClient.Write without OverwriteIfExists produces a bare "file already exists: <path>" with no --force hint. Passing true here and always including OverwriteIfExists for the filer restores the base code's intent and avoids the inconsistent error.
There was a problem hiding this comment.
Passing force through lets the YAML saver refuse a root it sees after preflight. The sidecar writer also opens with O_EXCL by default, so a file created in that interval is preserved. Unconditional overwrite would let a conversion without --force silently replace it.
✅ Integration test reportCommit: e7c837b
Top 6 slowest tests (at least 2 minutes):
|
pardis-beikzadeh-db
left a comment
There was a problem hiding this comment.
My earlier comments are addressed.
Changes
Check the bundle roots and planned sidecars before writing. Report ordinary conflicts together and suggest
--forceonly when it can resolve them all. Return the first filesystem lookup failure. A different workload’s bundle is refused during this same check, even with--force.Why
If an earlier conversion left sidecars behind, converting a different workload could fail after writing its new bundle root. The resulting bundle could then run the old workload’s command.
These examples start with the same two workload files. An initial conversion of
a.yamlwritespython a.pytogenerated_artifacts/command.sh. The second workload,b.yaml, specifiespython b.py. Both include hyperparameters.Before
After
Tests
The collision table checks the exact error and compares the files before and after failure. The CLI acceptance case removes the generated root, retries conversion, and verifies the root stays absent. A separate regression verifies that refusing a different workload leaves a missing sidecar directory absent.
This PR was written with Codex.