Skip to content

Fix: reject fix flags with JSON/SARIF output#138

Merged
avifenesh merged 2 commits intomainfrom
codex/issue-128-fix-flags
Feb 3, 2026
Merged

Fix: reject fix flags with JSON/SARIF output#138
avifenesh merged 2 commits intomainfrom
codex/issue-128-fix-flags

Conversation

@avifenesh
Copy link
Copy Markdown
Collaborator

Summary

  • reject --fix/--dry-run/--fix-safe when --format json or sarif is used
  • add CLI integration coverage for rejected flag combos
  • document fix-flag restriction in README

Test Plan

  • cargo test -p agnix-cli

Related Issues

Closes #128

Copilot AI review requested due to automatic review settings February 3, 2026 16:19
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @avifenesh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the command-line interface by introducing a validation rule that prevents the use of automated fixing flags with structured output formats like JSON and SARIF. This change ensures that users receive clear error messages when attempting to combine these incompatible options, thereby improving the robustness and user experience of the tool. It also includes comprehensive test coverage and updated documentation to reflect this new behavior.

Highlights

  • CLI Argument Validation: The CLI now explicitly rejects the use of fix flags (--fix, --dry-run, --fix-safe) when the output format is specified as JSON or SARIF, ensuring that these incompatible combinations result in an error.
  • Documentation Update: The README.md has been updated to clearly state that fix flags are only supported when using text output.
  • Integration Test Coverage: New integration tests have been added to verify that the CLI correctly rejects these unsupported flag combinations for both JSON and SARIF output formats.
Changelog
  • README.md
    • Added a new feature bullet point under both JSON and SARIF sections clarifying that fix flags are only supported with text output.
  • crates/agnix-cli/src/main.rs
    • Introduced a check in validate_command to detect if any fix flag is used with a non-text output format (JSON or SARIF).
    • Returns an anyhow::Error with a descriptive message if an unsupported combination is found.
    • Refactored the should_fix variable initialization to occur earlier in the function.
  • crates/agnix-cli/tests/cli_integration.rs
    • Added a new helper function assert_fix_flags_rejected to streamline testing for rejected flag combinations.
    • Implemented test_fix_flags_rejected_for_json_and_sarif to test all permutations of fix flags (--fix, --dry-run, --fix-safe) with JSON and SARIF formats.
    • Updated test_dry_run_with_format_json to use the new assert_fix_flags_rejected helper, confirming that --dry-run with JSON format is now correctly rejected.
Activity
  • The pull request introduces a new validation rule for CLI arguments to prevent incompatible flag combinations.
  • It includes updates to the README.md to document the new restriction.
  • Comprehensive integration tests have been added to ensure the new validation logic works as expected.
  • This PR addresses and closes issue Fix flags ignored with JSON/SARIF output #128, resolving a previously identified problem.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements a restriction to prevent the use of fix-related flags (--fix, --dry-run, --fix-safe) with machine-readable output formats (json, sarif). The implementation is clean, using an early return in validate_command to reject invalid flag combinations. The change is accompanied by a good refactoring that removes a redundant variable definition. The addition of comprehensive integration tests ensures the new restriction is well-covered, and the update to the README.md clearly documents this new limitation for users. Overall, this is a high-quality contribution that improves the tool's robustness and user experience.

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 issue #128 where fix flags (--fix, --dry-run, --fix-safe) were silently ignored when used with JSON or SARIF output formats. The fix adds early validation to explicitly reject these incompatible flag combinations with a clear error message.

Changes:

  • Added validation logic to reject fix flags when used with non-text output formats
  • Added comprehensive test coverage for all rejected flag combinations (6 scenarios)
  • Refactored existing test to use new shared helper function
  • Updated README documentation to clarify that fix flags only work with text output

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
crates/agnix-cli/src/main.rs Moved should_fix calculation earlier and added validation to reject fix flags with JSON/SARIF formats before processing
crates/agnix-cli/tests/cli_integration.rs Added helper function and comprehensive test covering all 6 flag combinations (2 formats × 3 flags), refactored existing test
README.md Added documentation notes in both JSON and SARIF output format sections clarifying fix flag restrictions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@claude
Copy link
Copy Markdown

claude Bot commented Feb 3, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@claude
Copy link
Copy Markdown

claude Bot commented Feb 3, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@avifenesh avifenesh merged commit 6bf097c into main Feb 3, 2026
13 checks passed
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.

Fix flags ignored with JSON/SARIF output

2 participants