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

    DocumentationenhancementNew feature or requestgitautoGitAuto label to trigger the app in a issue.good first issueGood for newcomershacktoberfestParticipation in the Hacktoberfest eventhelp wantedExtra attention is needed✨ featureNew feature requests or implementations👷🏼 infrastructureInfrastructure-related tasks or issues📝 documentationTasks related to writing or updating documentation🕓 medium effortA task that can be completed in a few hours🚀 performancePerformance optimizations or regressions🚨 securitySecurity-related issues or improvements🛠 WIPWork in progress🧪 testsTasks related to testing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions