Skip to content
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(amazonq): zip entry contains invalid characters #5274

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ctlai95
Copy link
Contributor

@ctlai95 ctlai95 commented Jan 16, 2025

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Code reviews sometimes fail due to invalid zip entry path error for certain workspace configurations.

Root cause:
The condition selectedFile.path.startsWith(projectRoot.path) string comparison incorrectly returns true if the selected file is not in the projectRoot but has a partial path prefix match of the projectRoot.

For example:

projectRoot.path = "/home/user/project"
selectedFile.path = "/home/user/project2/some/file.java"

Solution:
Use built-in VirtualFile util method to check if the file is actually within the projectRoot.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ctlai95 ctlai95 marked this pull request as ready for review January 17, 2025 00:17
@ctlai95 ctlai95 requested review from a team as code owners January 17, 2025 00:17
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.

1 participant