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

Revert "Replace path.Join with filepath.Join (#856)" #887

Merged
merged 15 commits into from
Dec 26, 2024
Merged

Conversation

osterman
Copy link
Member

@osterman osterman commented Dec 23, 2024

This reverts commit 2051592.

what

why

Summary by CodeRabbit

  • Bug Fixes
    • Updated path handling across multiple files to use a more appropriate method for constructing paths.
  • Documentation
    • Adjusted comments and logging to reflect changes in path construction.
  • Tests
    • Modified test cases to utilize the updated path handling method, ensuring consistency across tests.
  • Chores
    • Updated GitHub Actions workflow to streamline acceptance test execution, enhancing maintainability.
  • New Features
    • Introduced a new function to sanitize filenames for better cross-platform compatibility.

@osterman osterman requested a review from a team as a code owner December 23, 2024 21:44
@mergify mergify bot added the triage Needs triage label Dec 23, 2024
Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

📝 Walkthrough

Walkthrough

The pull request introduces a systematic replacement of filepath.Join with path.Join across multiple files in the Atmos project. This change primarily affects path construction methods, transitioning from operating system-specific path handling to a more generic URL-like path joining approach. The modifications span various packages and functions, focusing on consistent path manipulation without altering core functionality or control flows.

Changes

File Path Change Summary
cmd/cmd_utils.go, cmd/docs.go Replaced filepath.Join with path.Join for path construction.
internal/exec/* Comprehensive replacement of filepath.Join with path.Join across multiple utility and execution files.
pkg/config/config.go, pkg/utils/* Updated path joining methods in configuration and utility functions.
Test files Modified path construction in test cases to use path.Join.
.github/workflows/test.yml Updated acceptance test execution method in the GitHub Actions workflow.

Suggested labels

patch

Suggested reviewers

  • osterman
  • aknysh
  • Gowiem

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adecd10 and d3b699d.

📒 Files selected for processing (1)
  • pkg/vender/vendor_config_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/vender/vendor_config_test.go

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🧹 Nitpick comments (31)
internal/exec/workflow.go (1)

7-7: Potential Windows compatibility concern
Replacing "filepath" with "path" may break cross-platform usage if the code relies on OS-specific separators.

cmd/docs.go (2)

7-7: Consider OS-specific path handling
Importing "path" might cause separator mismatches on Windows.


62-62: Cross-platform path caution
Using "path.Join" can lead to breakage if Windows file paths are involved.

pkg/generate/terraform_generate_varfiles_test.go (1)

31-31: Potential Windows path issue in tests
"filePattern" may not match expected directory structures on Windows.

internal/exec/terraform_generate_backend.go (1)

78-78: Double-check file path handling
Switching to "path.Join" could disrupt Windows support unless that's not a concern.

internal/exec/oci_utils.go (2)

11-11: Evaluate cross-platform requirements for OCI workflows
Using "path" may ignore Windows path delimiters.


94-94: Layer extraction path caution
"filepath.Join" is recommended if layer paths must be valid on Windows.

pkg/vender/component_vendor_test.go (4)

5-5: Consider using 'filepath' if targeting OS-specific paths.
You’re importing "path", which treats paths as URL-like. If these are filesystem-specific paths, replacing "path" with "filepath" might be safer for cross-platform compatibility (especially on Windows).


32-37: Potential filesystem compatibility concern.
All these path joins use "path.Join(...)" rather than "filepath.Join(...)", which may not respect Windows path separators. If you’re dealing with local paths, consider "filepath.Join".


48-64: Same OS compatibility concern.
Again, these lines rely on "path.Join(...)". Only use "path" if paths are URL-like or platform-agnostic.


67-85: Confirm file deletion logic with OS-specific semantics.
The "os.Remove(...)" and "os.RemoveAll(...)" calls will succeed, but if the broader codebase requires OS-consistent path handling, switching these joins from "path" to "filepath" is recommended.

pkg/vender/vendor_config_test.go (5)

7-7: Check whether local or URL paths.
Importing "path" will treat paths as URL-like. For local paths, "filepath" is generally a more reliable cross-platform choice.


31-31: Platform-agnostic path usage.
"componentPath := path.Join(...)" might behave unexpectedly on Windows if the code expects local filesystem semantics.


87-87: Candidate for 'filepath.Join'.
Since this references a file on disk, "filepath.Join" is suggested for operating-system consistency.


105-105: Nonexistent file test logic.
Using "path.Join" here can pass the incorrect path on certain OSes. If the test is intended for all OSes, switching to "filepath.Join" is safer.


129-129: Path join inside local filesystem.
This can cause confusion if the code eventually runs on Windows with backslashes in the path.

pkg/utils/file_utils.go (1)

72-72: Cross-platform join check.
At line 72, "path.Join" might cause issues on Windows. If these are pure filesystem paths, switch to "filepath.Join".

internal/exec/terraform_utils.go (3)

8-8: Mixed path imports.
You’re importing both "path" and "filepath". Consolidate your approach: generally "filepath" is standard for local file manipulation.


91-91: Adjust for local file usage.
"backendFileName := path.Join(...)" is likely operating-system dependent. If these are truly local filesystem paths, prefer "filepath.Join".


124-124: Maintain cross-platform compatibility.
Using "path.Join" for the "providers_override.tf.json" path can lead to unexpected results on Windows.

internal/exec/stack_utils.go (1)

167-167: Ensure consistency in path handling for Terraform components
Double-check whether the component paths are expected to be OS-agnostic or purely slash-based paths. If they are local file system paths, revert to “filepath.Join” for local compatibility.

internal/exec/workflow_utils.go (2)

6-6: Use “filepath” instead of “path” for local paths
For multi-platform support, consider reverting to “filepath” imports for handling local directories.


150-150: Reevaluate “path.Join” for workflows
If these workflow definitions point to local file paths, revert to “filepath.Join” to avoid OS path separator issues.

internal/exec/terraform_generate_backends.go (1)

294-294: Revert to “filepath.Join” for local file creation
Backends are typically stored in local directories. Using “filepath.Join” will ensure correctness on different operating systems.

pkg/config/config.go (3)

136-136: Check if this path needs OS-aware handling.
Replacing filepath.Join with path.Join may introduce unexpected behavior on Windows.


165-165: Assess cross-platform implications.
While simpler, path.Join may fail if components contain backslashes on Windows.


192-192: Check uniform usage of path joining logic.
Having both path and filepath in the same file can be confusing.

internal/exec/describe_affected_utils.go (2)

1185-1187: Assess if path.Join is valid for the 'component' argument.
On Windows, a backslash can creep in and cause mismatch.


1244-1244: Ensure path.Join is correct for module calls.
If these paths are always local file references, consider reverting to filepath.Join.

internal/exec/stack_processor_utils.go (1)

375-375: Consider fallback to filepath for template lookups.
Local-based lookups often rely on OS-specific separators.

pkg/utils/glob_utils.go (1)

39-39: Traverse results carefully on Windows.
Forward slash separators might break local references in certain edge cases.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a27442 and ddf1af2.

📒 Files selected for processing (25)
  • cmd/cmd_utils.go (2 hunks)
  • cmd/docs.go (3 hunks)
  • internal/exec/atlantis_generate_repo_config.go (2 hunks)
  • internal/exec/aws_eks_update_kubeconfig.go (2 hunks)
  • internal/exec/describe_affected_utils.go (4 hunks)
  • internal/exec/helmfile.go (3 hunks)
  • internal/exec/oci_utils.go (3 hunks)
  • internal/exec/stack_processor_utils.go (3 hunks)
  • internal/exec/stack_utils.go (2 hunks)
  • internal/exec/terraform_generate_backend.go (2 hunks)
  • internal/exec/terraform_generate_backends.go (3 hunks)
  • internal/exec/terraform_generate_varfiles.go (2 hunks)
  • internal/exec/terraform_utils.go (3 hunks)
  • internal/exec/validate_component.go (3 hunks)
  • internal/exec/validate_stacks.go (4 hunks)
  • internal/exec/vendor_component_utils.go (3 hunks)
  • internal/exec/vendor_utils.go (2 hunks)
  • internal/exec/workflow.go (2 hunks)
  • internal/exec/workflow_utils.go (3 hunks)
  • pkg/config/config.go (8 hunks)
  • pkg/generate/terraform_generate_varfiles_test.go (2 hunks)
  • pkg/utils/file_utils.go (2 hunks)
  • pkg/utils/glob_utils.go (2 hunks)
  • pkg/vender/component_vendor_test.go (3 hunks)
  • pkg/vender/vendor_config_test.go (6 hunks)
✅ Files skipped from review due to trivial changes (8)
  • internal/exec/atlantis_generate_repo_config.go
  • cmd/cmd_utils.go
  • internal/exec/validate_component.go
  • internal/exec/aws_eks_update_kubeconfig.go
  • internal/exec/terraform_generate_varfiles.go
  • internal/exec/vendor_utils.go
  • internal/exec/helmfile.go
  • internal/exec/validate_stacks.go
🔇 Additional comments (16)
internal/exec/workflow.go (1)

83-83: Recommend verifying path correctness on all platforms
If Windows usage is expected, consider reverting to "filepath.Join" to avoid separator issues.

pkg/generate/terraform_generate_varfiles_test.go (1)

5-5: Check for platform consistency
Importing "path" can lead to inconsistent file patterns on Windows.

internal/exec/terraform_generate_backend.go (1)

5-5: Platform-aware path usage
"filepath" is typically used for local file system paths. Confirm if "path" suffices.

✅ Verification successful

Let me verify how the path package is being used in this context.

This will help us understand:

  1. How the path package is being used in the context
  2. Whether filepath is already present
  3. The specific path operations being performed

Using path package is correct in this context

The path package is being used to join path components for generating a backend configuration file path that will be used in Terraform configuration. Since this appears to be for generating paths that will be used within Terraform's configuration (which uses forward slashes regardless of the platform), using the path package is actually the correct choice here instead of filepath. The path package always uses forward slashes which is exactly what we want for Terraform configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Check the usage of path package in the file
rg -A 5 -B 5 'path\.' internal/exec/terraform_generate_backend.go

# Check if filepath package is also imported or used
rg 'filepath' internal/exec/terraform_generate_backend.go

# Look at the complete context of path usage
ast-grep --pattern 'path.$_($_)'

Length of output: 485

internal/exec/stack_utils.go (2)

5-5: Consider reverting to “filepath” for file paths on local systems
“path” is typically for URL paths; for improved cross-platform compatibility involving file system paths, “filepath” is more appropriate.


169-169: Confirm Helmfile component path usage
Similar to the comments above, confirm that the Helmfile base path is truly OS-agnostic before finalizing the use of “path.Join.”

✅ Verification successful

Let me verify the usage of path joining in the codebase to ensure OS compatibility.

This will help us understand:

  1. Which path joining method is consistently used
  2. Whether the imports indicate awareness of OS-specific path handling

Let me check more thoroughly by examining the imports and overall path handling patterns in the file.


Path handling is correctly implemented
The code is using the standard path package (imported as "path") which is designed specifically for slash-separated paths and is OS-agnostic. The implementation consistently uses path.Join throughout the file for both Terraform and Helmfile component paths, making it safe for cross-platform usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for path joining usage patterns in the codebase
rg -A 2 "path\.Join|filepath\.Join" internal/exec/stack_utils.go

# Look for any imports of path/filepath packages
rg "^import.*\"path\".*|^import.*\"path/filepath\".*" internal/exec/stack_utils.go

Length of output: 429


Script:

#!/bin/bash
# Get the full content of the file to analyze imports and path handling
cat internal/exec/stack_utils.go

# Also check for any tests that might reveal path handling expectations
fd stack_utils_test.go --exec cat {}

Length of output: 8080

internal/exec/terraform_generate_backends.go (1)

164-164: Check the base path usage
Consider using “filepath.Join” if the path references a folder in a local environment so that Windows path separators are respected.

internal/exec/vendor_component_utils.go (1)

9-9: Avoid mixing “path” for local file paths
When dealing with real files in operating systems, “filepath” is safer.

pkg/config/config.go (5)

296-296: Maintain consistent path joining for Terraform base path.
Ensure environment-specific paths don’t conflict with path.Join usage.
[approve]


304-304: Same note applies to helmfileBasePath.
Double-check if path.Join fits all usage patterns.

✅ Verification successful

Let me search for how helmfileBasePath is being used in the codebase to verify if path.Join is appropriate for all usage patterns.


path.Join usage for helmfileBasePath is appropriate and verified

The code analysis shows that helmfileBasePath is used correctly in a path joining operation. It's immediately converted to an absolute path using filepath.Abs(), which is the proper way to handle filesystem paths. The usage pattern is consistent with the codebase's path handling requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for usages of helmfileBasePath
rg "helmfileBasePath" -A 3 -B 3

# Also search for any path manipulation patterns related to helmfile
rg "helmfile.*Path" -A 3 -B 3

Length of output: 14511


274-274: Watch out for Windows path separators.
Using path.Join here could break if the BasePath and Stacks.BasePath are mixed with backslashes.


8-8: Consider platform-specific nuances when using path.Join.
For OS-agnostic file paths (including Windows), filepath.Join might be more reliable.


151-151: Confirm consistency across all configuration paths.
This usage of path.Join can lead to cross-platform issues if called from Windows-based scripts.

internal/exec/describe_affected_utils.go (2)

1223-1223: Check local module references for Windows.
Using path.Join may result in broken references on certain systems.


435-437: Double-check cross-platform paths for stack elements.
Replacing filepath with path might be risky if these are local filesystem paths rather than URL paths.

✅ Verification successful

Let me gather more information about the path handling in this codebase.

This will help us understand:

  1. The current path handling approach in the file
  2. Whether filepath package is imported and used elsewhere
  3. If there's any OS-specific path handling logic
  4. The import statements to confirm which package is being used

Let me check the imports more thoroughly to understand the complete context.


The path handling is correct as implemented.

The code correctly uses both path and filepath packages based on their intended purposes:

  • path.Join is used for constructing logical paths that are part of the Atmos configuration (BasePath, Components paths)
  • filepath is used for actual filesystem operations (Abs, Rel) when dealing with the local filesystem

The codebase shows a consistent pattern where:

  1. Configuration paths use the path package for cross-platform consistency
  2. Actual filesystem operations use filepath for OS-specific path handling
  3. Both packages are properly imported and used according to Go's best practices
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Check for other usages of path vs filepath in the codebase
rg "path\." -A 2 internal/exec/describe_affected_utils.go

# Look for any platform-specific path handling
rg "filepath\." -A 2 internal/exec/describe_affected_utils.go

# Check imports to see which package is being used
rg "^import.*path" internal/exec/describe_affected_utils.go
rg "^import.*filepath" internal/exec/describe_affected_utils.go

# Look for any OS-specific path handling patterns
ast-grep --pattern 'if runtime.GOOS == $_'

Length of output: 3741


Script:

#!/bin/bash
# Check the full import block
rg "^import \(" -A 20 internal/exec/describe_affected_utils.go

# Check if this file has any OS-specific imports
rg "runtime|os" internal/exec/describe_affected_utils.go

# Look for any path manipulation utility functions
ast-grep --pattern 'func $_(path $_) $_'

Length of output: 10452

internal/exec/stack_processor_utils.go (1)

2183-2183: Confirm that baseComponent now uses path.Join.
If the component directory resides on Windows, validate that path.Join won't break references.
[approve]

pkg/utils/glob_utils.go (1)

6-6: Mixing path and OS-based file lookups can lead to confusion.
Check if intended usage is for file system or URL paths.

✅ Verification successful

Let me gather more information about the usage of the path package in the codebase to verify this concern.

This will help us understand:

  1. The full context of the glob_utils.go file
  2. How the path package is being used
  3. If there's any mixing with filepath package that could cause confusion

After analyzing the code, I can now provide a definitive response about the usage of the path package in glob_utils.go.

The path package usage here is correct and intentional.
The code is using path package specifically for path manipulation in a platform-agnostic way, while also providing a clear PathMatch function that serves as a drop-in replacement for filepath.Match() with explicit documentation about path separators. The code shows a clear understanding of when to use each:

  • path.Join is used for clean path joining in a platform-agnostic way
  • filepath functions are properly used when dealing with the actual filesystem
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# First, let's see the content of the file to understand the context
cat pkg/utils/glob_utils.go

# Then, let's search for usage of path-related functions across the codebase
rg "path\." -A 2

# Also check for filepath package usage to see if there's mixing
rg "filepath\." -A 2

Length of output: 63017

cmd/docs.go Show resolved Hide resolved
internal/exec/oci_utils.go Show resolved Hide resolved
pkg/vender/vendor_config_test.go Outdated Show resolved Hide resolved
pkg/utils/file_utils.go Show resolved Hide resolved
internal/exec/workflow_utils.go Show resolved Hide resolved
internal/exec/vendor_component_utils.go Outdated Show resolved Hide resolved
internal/exec/vendor_component_utils.go Outdated Show resolved Hide resolved
pkg/config/config.go Show resolved Hide resolved
internal/exec/stack_processor_utils.go Show resolved Hide resolved
internal/exec/stack_processor_utils.go Show resolved Hide resolved
Copy link

mergify bot commented Dec 23, 2024

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label Dec 23, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
internal/exec/vendor_utils.go (1)

Line range hint 1-645: Consider implementing a platform-agnostic path handling strategy

Given the history of path-related issues (mentioned in PR #856) and the addition of Windows-specific handling, consider:

  1. Creating a centralized path handling utility
  2. Documenting the path handling strategy
  3. Adding integration tests for cross-platform scenarios

This would help prevent future path-related issues and make the codebase more maintainable.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac1a504 and 0ba32ea.

📒 Files selected for processing (1)
  • internal/exec/vendor_utils.go (4 hunks)
🔇 Additional comments (2)
internal/exec/vendor_utils.go (2)

6-8: Both path and filepath packages are imported

This could lead to confusion as both packages are used for path manipulation. The PR description mentions reverting from filepath.Join to path.Join, but both imports remain.

Let's check the usage patterns:

✅ Verification successful

Both path and filepath packages are used appropriately

Based on the usage patterns found in the codebase:

  • path.Join is primarily used for handling URL-style paths and configuration paths that need to be platform-independent
  • filepath.Join is correctly used for filesystem operations where OS-specific path separators are required

The coexistence of both packages is intentional and follows Go's best practices:

  • path for virtual/URL paths (platform-independent)
  • filepath for actual filesystem paths (platform-specific)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check usage patterns of path.Join and filepath.Join
echo "Checking path.Join usage:"
rg "path\.Join\(" -A 1

echo -e "\nChecking filepath.Join usage:"
rg "filepath\.Join\(" -A 1

Length of output: 24000


556-558: Ensure consistent path handling across platforms

The usage of sanitizeFileName here is good, but we should ensure consistent path handling across all platforms.

Let's check for similar patterns that might need the same treatment:

✅ Verification successful

Let me check for any instances where file paths are constructed without proper sanitization. I'll search for direct file path construction patterns.


Let me check the implementation of the sanitizeFileName function to ensure it's properly handling paths.


Let me see the complete implementation of sanitizeFileName since it was cut off.


Let me get the complete function implementation as it seems to be cut off.


Path handling is properly implemented and secure

The sanitizeFileName function is well-implemented with proper platform-specific handling:

  • On non-Windows systems, it safely extracts the base filename
  • On Windows, it properly sanitizes invalid characters and handles query strings
  • The function is correctly used in the codebase for safe filename construction

All other instances of filepath.Join in the codebase are used appropriately for path construction, and don't require additional sanitization as they're working with internal paths rather than external URIs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Look for other instances where file paths are constructed
rg "filepath\.Join\([^)]*\)" -A 1

Length of output: 5968


Script:

#!/bin/bash
# Look for direct file path construction without sanitization
rg "filepath\.Join.*\(" -C 2 internal/exec/

Length of output: 12862


Script:

#!/bin/bash
# Check for the sanitizeFileName function implementation and usage
ast-grep --pattern 'func sanitizeFileName($_) { $$$ }'

Length of output: 56


Script:

#!/bin/bash
# Look for other file name handling functions
rg "func.*[Ff]ile[Nn]ame" -A 2

Length of output: 2685


Script:

#!/bin/bash
# Get the implementation of sanitizeFileName
rg -A 10 "func sanitizeFileName" internal/exec/vendor_utils.go

Length of output: 355


Script:

#!/bin/bash
# Get the complete implementation of sanitizeFileName with more context
rg -A 20 "func sanitizeFileName" internal/exec/vendor_utils.go

Length of output: 623


Script:

#!/bin/bash
# Get the complete implementation with more lines
rg -A 30 "func sanitizeFileName" internal/exec/vendor_utils.go

Length of output: 928


Script:

#!/bin/bash
# Look for any calls to this function
rg "sanitizeFileName\(" internal/exec/

Length of output: 184

internal/exec/vendor_utils.go Show resolved Hide resolved
internal/exec/vendor_utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/exec/vendor_model_component.go (1)

162-162: Avoid duplicating path-sanitization logic.

"tempDir2 = filepath.Join(tempDir, sanitizeFileName(p.uri))" repeats the logic at line 127. Consider extracting this path creation into a helper method to improve reusability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba32ea and bec23de.

📒 Files selected for processing (3)
  • internal/exec/vendor_component_utils.go (4 hunks)
  • internal/exec/vendor_model.go (1 hunks)
  • internal/exec/vendor_model_component.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • internal/exec/vendor_model.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/exec/vendor_component_utils.go
🔇 Additional comments (1)
internal/exec/vendor_model_component.go (1)

127-127: Consider validating the sanitized path.

Using "sanitizeFileName(p.uri)" is effective for removing invalid path characters. However, ensure that sanitized names don't become empty or produce collisions if different URIs map to the same sanitized value.

@osterman osterman added minor New features that do not break anything and removed triage Needs triage labels Dec 25, 2024
This was referenced Dec 25, 2024
@aknysh aknysh merged commit 02bbeb9 into main Dec 26, 2024
46 checks passed
@aknysh aknysh deleted the revert-2051592c branch December 26, 2024 14:44
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Dec 26, 2024
Copy link

These changes were released in v1.131.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants