Skip to content

Conversation

@sibasispadhi
Copy link
Contributor

This commit fixes issue #5673 where 'flux build kustomization' fails on Windows when using --path with relative or absolute paths.

The bug manifested as duplicate path components:
C:\path\test\C:\path\test\kustomization.yaml.original

Root cause: The path argument was passed directly without normalization, causing issues in downstream path joining.

Fix: Normalize the path using filepath.Abs() and filepath.Clean() before passing it to the builder. This ensures:

  • Relative paths are converted to absolute paths
  • Windows path separators are handled correctly
  • Path components are cleaned and deduplicated

Added unit tests to verify path normalization works correctly on both Linux and Windows platforms.

Fixes #5673

@stefanprodan stefanprodan added the area/diff Diff related issues and pull requests label Jan 13, 2026
@stefanprodan
Copy link
Member

Please run make fmt and force push.

sibasispadhi added a commit to sibasispadhi/flux2 that referenced this pull request Jan 13, 2026
The previous test was testing Go's filepath.Abs/Clean functions
instead of testing the Flux code itself.

New test:
- Actually runs 'flux build kustomization' command
- Tests different path formats (relative with/without ./)
- Verifies the command produces correct output
- Follows the same pattern as existing tests in the file

This properly tests that the Flux code normalizes paths correctly,
not just that the Go standard library works.

Addresses review feedback on PR fluxcd#5674.

Signed-off-by: Sibasis Padhi <[email protected]>
Comment on lines 234 to 240
args: "build kustomization podinfo --path testdata/build-kustomization/podinfo",
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "build with dot-slash relative path",
args: "build kustomization podinfo --path ./testdata/build-kustomization/podinfo",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These paths are too simple and don't test what's changing here. The initial paths from Windows seemed much better in that regard. Maybe we can adapt them to Linux paths?

P.S.: The vibe-coding is wasting a bit of my time 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, future is vibe coding. It will get used to soon. Let me recheck & get back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. please take a look when possible. The git should be integrated with a code reviewer agent, thats flush out initial issues before going to actual reviewers. That will save time. I am sure CNCF & other teams would be already thinking about it as that is the the vibe coding future. Have fixed it again, please take a look when possible :) . This time my code-assistant said, you will be happy & sorry :). Lets see !! :--)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, are you suggesting to take out the test case all together ?

Copy link
Member

@matheuscscp matheuscscp Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using AI effectively and with other people's time in mind is good. Vibe-coding is not.

sibasispadhi added a commit to sibasispadhi/flux2 that referenced this pull request Jan 13, 2026
Previous tests were too simple. Now testing paths that would
actually expose concatenation bugs without normalization:

1. Absolute paths (like Windows C:\path issue)
2. Paths with parent directory (..) that need cleaning
3. Paths with redundant separators (//) that need normalization

These tests verify the fix prevents path duplication like:
  /path/test/path/test/file (without normalization)
  /path/test/file (with proper normalization)

Addresses review feedback on PR fluxcd#5674.

Signed-off-by: Sibasis Padhi <[email protected]>
@matheuscscp
Copy link
Member

Please squash, this PR should have a single commit

@matheuscscp matheuscscp added the backport:release/v2.7.x To be backported to release/v2.7.x label Jan 13, 2026
Fixes fluxcd#5673

On Windows, when using absolute paths like C:\path\to\dir,
the path could be incorrectly concatenated, resulting in:
C:\working\dir\C:\path\to\dir\file

This fix applies filepath.Abs() and filepath.Clean() to normalize
the path before using it, ensuring absolute paths are handled
correctly on all platforms.

Changes:
- Apply filepath.Abs() to convert relative paths to absolute
- Apply filepath.Clean() to remove redundant separators and resolve ..
- Add tests for absolute paths, complex paths with .., and paths
  with redundant separators to verify normalization works correctly

The tests use actual 'flux build kustomization' commands with:
1. Absolute paths (prevents concatenation bugs)
2. Paths with parent directory (..) references
3. Paths with redundant separators (//)

All tests verify the command produces correct output, ensuring
the path normalization fix works as expected.

Signed-off-by: Sibasis Padhi <[email protected]>
@sibasispadhi sibasispadhi force-pushed the fix-windows-path-issue-5673 branch from 64b3103 to 7dd9fde Compare January 13, 2026 16:27
@sibasispadhi
Copy link
Contributor Author

thank you for the review, @matheuscscp .done

Copy link
Member

@matheuscscp matheuscscp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matheuscscp matheuscscp merged commit c125bcb into fluxcd:main Jan 13, 2026
6 checks passed
@fluxcdbot
Copy link
Member

Successfully created backport PR for release/v2.7.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/diff Diff related issues and pull requests backport:release/v2.7.x To be backported to release/v2.7.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flux build kustomization fails on Windows

4 participants