tp: export ErrMissingUserURLCallback - #47
Merged
Merged
Conversation
A client with no WithUserURLCallback cannot finish a discharge that the third party wants to hand to the user's browser, and callers that can supply one want to retry when they see it. The error carrying that was an inline errors.New, so the only way to recognise it was to match on its message, which is not something a caller should have to depend on. Export it as a sentinel. The message is unchanged, so existing string matching keeps working, and errors.Is sees through the joined error that FetchDischargeTokens returns for a set of tickets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns the "missing user-url callback" error into an exported sentinel so callers can recognise it with
errors.Isinstead of matching on its message.Context
A client built without
WithUserURLCallbackcannot complete a discharge that the third party wants to hand to the user's browser, anddoUserInteractivesays so. That is a useful signal rather than a dead end: a caller that can open a browser but would rather not pay for the sequential, one-at-a-time flow can run the parallel pass first, see this error, and retry with a callback attached. flyctl does exactly that.Until now the only way to recognise it was
strings.Contains(err.Error(), "missing user-url callback"), against an inlineerrors.Newthat nothing promised to keep stable. Rewording it here would silently switch that caller off: no browser, no interactive discharge, and a debug log as the only trace.Details
The message is unchanged, so existing string matching keeps working and this is safe to take on its own schedule.
FetchDischargeTokensjoins the per-ticket errors, anderrors.Issees througherrors.Join, so a caller can test the error for a whole set of tickets. The new test intp_test.goasserts that.