Skip to content

[FEATURE] Add DOTNET_AICOMMITMESSAGE_IGNORE_API_ERRORS environment variable to bypass AI API failures gracefullyΒ #285

@guibranco

Description

@guibranco

I'm using dotnet-aicommitmessage to generate commit messages based on branch name, commit message, and git diff via an AI model. However, in some environments (e.g., corporate or restricted networks), API calls to the AI provider may fail due to network restrictions or policies.

Currently, when an API error occurs, the tool throws an exception internally and simply returns the original message without any transformation, which can interrupt workflows unexpectedly.


🧩 Feature Request

Introduce a new environment variable:
DOTNET_AICOMMITMESSAGE_IGNORE_API_ERRORS=true

When this variable is set:

  • If a network/API error occurs when calling the AI model, the tool should gracefully catch and suppress the exception.

  • Instead of failing, it should continue processing and fallback to returning the original or partially transformed message as needed.

This would be especially helpful in CI/CD pipelines or developer environments where occasional API issues shouldn't block the commit process.


βœ… Existing Related Functionality

There is already a -skipai flag that can be appended to the commit message (e.g., -skipai) to skip AI processing entirely. This new env variable would complement that by providing a more transparent fallback mechanism when issues arise, without requiring changes to individual commit messages.


πŸ’‘ Suggested Behavior

Scenario -skipai Present DOTNET_AICOMMITMESSAGE_IGNORE_API_ERRORS Set AI API Down Result
βœ… Yes No Yes/No AI is skipped, no API call
βœ… No Yes Yes Graceful fallback, no crash
❌ No No Yes Current behavior: throws exception and returns unmodified message

πŸ“Œ Notes

  • This should ideally log a warning (not error) when DOTNET_AICOMMITMESSAGE_IGNORE_API_ERRORS is active and an exception occurs, to aid debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions