Skip to content

Do not use LibGit2SharpException overload for unknown message #2163

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zentron
Copy link
Contributor

@zentron zentron commented Jul 19, 2025

Background

The LibGit2SharpException class has a constructor overload that takes two parameters and attempts to call String.Format to convert the values into a single string.

Unfortunately if the provided message contains text between curly braces then the string.format throws an exception.

Related PR OctopusDeploy#10

Result

Since this message could have any value, it seems risky to assume that the provided string will have a {0} that will accept the GitErrorCategory as a replacement value. In fact it seems rather unlikely that this would typically apply at all. As a result this handler would ignore the error category in the best case, or throw an exception in the worst case.

Alternative

I'd also be happy to ignore the category entirely since its likely that it is of type GitErrorCategory.Unknown anyway

Alternative snippet

exceptionBuilder = (m, c) => new LibGit2SharpException(m);

@zentron
Copy link
Contributor Author

zentron commented Jul 19, 2025

@bording this is related to a closed issue #2159

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.

1 participant