-
Notifications
You must be signed in to change notification settings - Fork 39
fix: prevent path duplication in model test command #601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent path duplication in model test command #601
Conversation
This fixes the issue reported in: openfga/action-openfga-test#32 The bug occurred when the CLI v0.7.7 changed how the --tests parameter resolves paths. The model test command was passing both: - fileName: the full path from glob (e.g., "my_project/infrastructure/fga/tests.fga.yaml") - basePath: path.Dir(fileName) (e.g., "my_project/infrastructure/fga") This caused ReadFromFile to join them, creating a duplicated path: "my_project/infrastructure/fga/my_project/infrastructure/fga/tests.fga.yaml" The fix passes an empty basePath since the file path from glob is already complete. ReadFromFile now correctly uses the file's directory internally for resolving nested file references (model_file, tuple_file). Changes: - Modified cmd/model/test.go to pass empty basePath to ReadFromFile - Added comprehensive unit tests in internal/storetest/read-from-input_test.go that verify the fix and prevent regression
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe PR fixes path duplication in test file resolution by changing how Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a path duplication bug in the model test command where passing path.Dir(file) as the basePath parameter to ReadFromFile caused the path to be joined incorrectly, creating duplicated paths like "path/to/file/path/to/file/test.yaml". The fix passes an empty basePath instead, allowing ReadFromFile to use the file's directory internally for resolving nested file references.
Key changes:
- Modified
cmd/model/test.goto pass an empty string asbasePathtoReadFromFile - Added comprehensive test coverage in
internal/storetest/read-from-input_test.goto validate the fix and prevent regression
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/model/test.go | Changed ReadFromFile call to pass empty basePath instead of path.Dir(file), with detailed explanation comment |
| internal/storetest/read-from-input_test.go | New test file covering path resolution scenarios including the bug case, correct usage with empty basePath, absolute paths, nested references, and error messages |
Comments suppressed due to low confidence (1)
cmd/model/test.go:22
- The
pathpackage import on line 22 is no longer used after removing thepath.Dir(file)call. This import should be removed to keep the imports clean.
"path"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot can you fix the lint issues pls! |
|
@Siddhant-K-code I've opened a new pull request, #602, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * fix: remove unused 'path' import from cmd/model/test.go Co-authored-by: Siddhant-K-code <55068936+Siddhant-K-code@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Siddhant-K-code <55068936+Siddhant-K-code@users.noreply.github.com>
|
/easycla |
|
Ahh, we wanted to get the claude get whitelisted for |
|
Fixed in #603 |
This fixes the issue reported in:
openfga/action-openfga-test#32
The bug occurred when the CLI v0.7.7 changed how the --tests parameter resolves paths. The model test command was passing both:
This caused ReadFromFile to join them, creating a duplicated path: "my_project/infrastructure/fga/my_project/infrastructure/fga/tests.fga.yaml"
The fix passes an empty basePath since the file path from glob is already complete. ReadFromFile now correctly uses the file's directory internally for resolving nested file references (model_file, tuple_file).
Changes:
Description
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
mainSummary by CodeRabbit
Bug Fixes
Tests