Prevent re-interpreting errors if they have placeholder patterns #785
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.
In my out-of-tree Complement tests, I was seeing instances of
%!F(MISSING)
appearing in my Complement logs when a matcher failed. It turns out that this was due to things that looked likeprintf
placeholders existing in my test data. Specifically, the URLhttps://127.0.0.1:6560/oauth2/authorize?response_type=code&client_id=test_idp_client_id&redirect_uri=http%3A%2F%2F127.0.0.1%3A8008%2F_synapse%2Fclient%2Foidc%2Fcallback&scope=read%3Auser
has things like%3A
and%2F
in it as there's a url-encoded URL in a query parameter.When the test failed and Complement went to print this out to me, it ended up re-interpreting the string with
t.Fatalf
, yet providing no arguments for the placeholders. This then results in the%3A
being replaced by%!A(MISSING)
as go could not find a corresponding variable.In this PR, I've replaced calls to
t.Fatalf
that had no argument witht.Fatal
instead. The result is below.Before:
After:
This works in my use case, though I'm not entirely sure if this would affect any other output. Notably, I think one would still have the same issue if they tried to use
must.NotError
, as that requires the use ofct.Fatalf
. Feedback welcome.Pull Request Checklist