Skip to content

fix: avoid false positives in import cycle detection#3449

Merged
AustinAbro321 merged 7 commits intomainfrom
fix-import
Jan 30, 2025
Merged

fix: avoid false positives in import cycle detection#3449
AustinAbro321 merged 7 commits intomainfrom
fix-import

Conversation

@AustinAbro321
Copy link
Copy Markdown
Member

@AustinAbro321 AustinAbro321 commented Jan 29, 2025

Description

Replaces the map cycle detection with a stack-based approach. The current approach caused false positives if multiple components import the same sub-package in a specific directory hierarchy because filepath.Join will clean the path causing it to look like the same import is occurring multiple times. Another potential solution is to use os.PathSeparator instead of filepath.Join to avoid cleaned filepaths

This PR instead uses a stack and only checks the current chain of imports to avoid false positives.

Related Issue

Fixes #3448

Checklist before merging

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 29, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit e41de71
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/679bd9a900e7040008313085

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/packager2/layout/import.go 90.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/packager2/layout/create.go 31.47% <100.00%> (ø)
src/internal/packager2/layout/import.go 38.55% <90.00%> (+24.05%) ⬆️

AustinAbro321 and others added 5 commits January 29, 2025 23:00
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@AustinAbro321 AustinAbro321 marked this pull request as ready for review January 30, 2025 15:42
@AustinAbro321 AustinAbro321 requested review from a team as code owners January 30, 2025 15:42
@AustinAbro321 AustinAbro321 changed the title fix: allow shared dependencies in import fix: avoid false positives in import cycle detection Jan 30, 2025
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Copy link
Copy Markdown
Contributor

@mkcp mkcp left a comment

Choose a reason for hiding this comment

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

LGTM

@AustinAbro321 AustinAbro321 added this pull request to the merge queue Jan 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2025
@AustinAbro321 AustinAbro321 added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit 345abaa Jan 30, 2025
26 checks passed
@AustinAbro321 AustinAbro321 deleted the fix-import branch January 30, 2025 21:20
nevinaragam pushed a commit to nevinaragam/zarf that referenced this pull request May 20, 2025
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: NevinAragam <nevin.aragam@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package can't import a component from a different package that shares a dependency

2 participants