Skip to content

Conversation

@Ibrahimrahhal
Copy link
Contributor

  • Fixed a bug where running scan --only-uncommitted with uncommitted changes that are all non-scannable files (e.g., CSS, scripts, or tests) resulted in creating an empty ZIP file instead of showing a message.
  • Started to show 400 API errors in the error message
image image

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a bug in the Corgea CLI where running scan --only-uncommitted with uncommitted changes that are all non-scannable files (CSS, scripts, tests, etc.) would create an empty ZIP file instead of providing a helpful error message. The changes also improve API error handling to surface more specific 400 Bad Request error messages from the server.

The core issue was addressed through three coordinated changes:

  1. Code consolidation in src/utils/generic.rs: The PR refactors hardcoded exclude patterns scattered across multiple functions into a single global constant DEFAULT_EXCLUDE_GLOBS. Previously, get_untracked_and_modified_files and create_zip_from_list_of_files had different sets of exclude patterns, which could lead to inconsistent filtering behavior. The consolidated patterns now include comprehensive file type exclusions (CSS, shell scripts, test files, IDE directories, etc.) that are applied consistently throughout the codebase.

  2. Enhanced API error handling in src/utils/api.rs: The upload_zip function now properly handles 400 Bad Request responses by reading the response text before attempting JSON parsing, preventing the response body from being consumed twice. When the API returns structured error messages (like ZIP validation failures), these are now extracted and displayed to users instead of generic error messages. Debug logging has also been improved for both initial scan requests and chunk uploads.

  3. Improved user messaging in src/scanners/blast.rs: The error message for the --only-uncommitted flag has been clarified to explain that while uncommitted changes may exist, they don't match scannable file types. This replaces a confusing message that suggested no uncommitted changes existed at all.

These changes work together to ensure that when users attempt to scan only uncommitted changes that are all non-scannable, they receive clear feedback about why the scan cannot proceed, rather than encountering empty ZIP file creation or generic error messages. The refactoring also improves code maintainability by eliminating duplication and centralizing configuration.

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it primarily improves error handling and consolidates existing logic
  • Score reflects well-structured refactoring with clear bug fixes, though the consolidated exclude patterns introduce a single point of failure that should be monitored
  • Pay close attention to src/utils/generic.rs to ensure the centralized DEFAULT_EXCLUDE_GLOBS patterns don't inadvertently exclude files that should be scannable

Context used:

Style Guide - Corgea Docs (link)

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@Ibrahimrahhal Ibrahimrahhal merged commit e7e5da5 into main Sep 7, 2025
14 checks passed
@Ibrahimrahhal Ibrahimrahhal deleted the zip_validation branch September 7, 2025 05:59
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.

4 participants