fix(patterns): use qp for nested pattern error messages#2868
Conversation
qp for nested pattern error messages
7941bca to
e0c8870
Compare
dckc
left a comment
There was a problem hiding this comment.
works for me, but I defer to more active maintainers (@kriskowal ) to approve
for golden tests, I find ava snapshots pretty handy
kriskowal
left a comment
There was a problem hiding this comment.
Please remove the ! from the commit message and PR description. If this is going to cause practical consequences for Agoric CI, please add a commit to endo-integration-master to reconcile or relax the overconstrained tests instead. You will likely need to verify this one with an endo-branch pinned in an Agoric SDK PR to validate that, but I prefer that over the eval twins we’ll inevitably have to iron out if we ramp the major version for error message changes, which I don’t consider part of our contract.
Also, please take care to remove the checklist from the end of the PR description so it doesn’t get preserved in the merge commit message.
qp for nested pattern error messagesqp for nested pattern error messages
82efbff to
43affe0
Compare
Thanks. I will keep that in mind next time I'm adding or maintaining tests with golden tests. Thanks! But it doesn't sound like you're requesting that shift in this PR. I agree that it isn't needed in this PR, so not doing it. |
Done
What is
Aside from "What is
Agreed.
Done |
In accord with our conversation, both Agoric/agoric-sdk#7937 and Agoric/agoric-sdk#9201 are rebased on agoric-sdk master. The only difference between them is the Watching. |
|
WOOHOO! Both Agoric/agoric-sdk#7937 and Agoric/agoric-sdk#9201 are green in CI, even though I'm just using |
Closes: #XXXX
Refs: #2799
Description
#2799 added a new
q-like quoter namedqp, for "quote passable", that renders any value into Justin source text. This was specifically motivated for displaying patterns within error messages in a readable and informative manner.The
@endo/patternspackage itself formulates many error messages to explain why a specimen did not match a pattern. Some of these message include quoted forms of nested patterns. But those were still quotes withq, leading @dckc to report still seeing error messages likeThis PR changes the quoting of nested errors to use
qpinstead, so a[match:splitRecord]might instead render asThis is more verbose. But error messages are designed to carry the critical clues to help find a bug. For nested patterns, this extra information is worth the verbosity.
Security Considerations
We were already quoting nested patterns with
q, unredacting them, under the assumption that specimens may carry secrets worth protecting from callers, but patterns typically do not. Switching these fromqtoqpis consistent with that assumption, but actually exposes info thatqhappened not to expose. When unredacting happened not to expose secrets it said were ok to expose, it is easy for developers not to notice the secrets that could have been shown but weren't. After this PR, these unredacted secrets will be exposed to callers.Scaling Considerations
Where
qis lazy,qpis eager, rendering its argument up front into Justin even if the containing error is never created or thrown. Thus, we must take care to only useqpwhen we're already committed to creating and throwing the error. I believe all such changes in this PR do so, and so do not add overhead to the happy path.Documentation Considerations
I don't know what documentation we provide explaining the interpretation of error messages. If we have any explain pattern match error messages, this PR might need us to change those explanations.
Testing Considerations
Using
qpto formulate the error messages definitely makes it more awkward to test is the error message is as expected. You can see this in the tests this PR needed to change. Fortunately, as shown in these error message tests, you can use${q(qp(...))}to formulate the golden in the test.Compatibility Considerations
Because this PR changes the error messages, as pointed out above, golden tests of error message text may no longer match, causing old working tests to start failing. However, this is not technically a compat break, because we take the stance that the content of error messages is not normative, so the error messages can become more informative over time with a version bump. Thus, I use
:rather than!to recommend that this PR not cause a version bump. (See #2868 (review) below)Upgrade Considerations
None.