Skip to content

feat(ses): Add assert.makeError and deprecate assert.error as an alias #2895

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 11 commits into
base: master
Choose a base branch
from

Conversation

gibson042
Copy link
Contributor

@gibson042 gibson042 commented Jul 16, 2025

...as the culmination of general cleanup.

Description

  • Make assert an arrow function, resolving a TODO
  • Rename StringablePayload to Stringable
  • Rename HiddenDetails to DetailsParts
  • Improve parameter/variable names
  • Improve type documentation and examples
  • Add assert.makeError and deprecate assert.error as an alias
  • Add an @endo/errors export of assert.details with its own name

Security Considerations

None known.

Scaling Considerations

n/a

Documentation Considerations

If accepted, agoric-sdk use of assert.error should be replaced with assert.makeError.

Testing Considerations

Existing coverage is sufficient.

Compatibility Considerations

assert.error is deprecated, but retained as an alias of assert.makeError to support existing code.

Upgrade Considerations

NEWS.md was updated to document the change.

@gibson042 gibson042 requested review from kriskowal and erights July 16, 2025 19:08
@gibson042 gibson042 force-pushed the gibson-2025-07-cleanup-ses-assert branch from 96d30b1 to 63d982a Compare July 16, 2025 19:48
Comment on lines -437 to -441
* to prevent revealing secrets up the exceptional path. In the example
* above, the thrown error may reveal only that `sky.color` is a string,
* whereas the same diagnostic printed to the console reveals that the
* sky was green. This masking can be disabled for an individual substitution value
* using `quote`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This concrete "green" example text deserves to go somewhere. Things moved around enough that perhaps I missed it, but AFAICT you seem to have dropped it.

(Extra credit if we can find a way to slip in an allusion to the Hume/Goldman "grue" and "bleen", but only if it does not detract from the explanation for normal users ;) .)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now the actual === expected || Fail`${actual} should be ${q(expected)}`; example for quote, but if you prefer the "sky" example I could switch that over.

payload: any,
spaces?: string | number,
): /** The declassified and quoted payload */ StringablePayload;
quote(value: any, spaces?: string | number): Stringable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Neither the old or new text say what the optional spaces parameter means, and I no longer remember. Would be nice to fix, but feel free not to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s the third arg to JSON.stringify and I forgot we threaded it. It’s not a great idea to thread it.

@@ -49,9 +53,10 @@ if (missing.length > 0) {
const {
bare,
details: redacted,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
details: redacted,
details: X,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better yet, normalize assert.X as the replacement for a deprecated assert.details, like this PR does for assert.makeError vs assert.error.

Need not be in this PR but I'd at least like your opinion ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the introduction of name redacted (and for that matter, likewise throwRedacted) is odd. This file exports both assert and properties thereof, the latter with both full names and "conventional abbreviations and aliases", and details is the only property that is exported but not with its literal name. I'm pushing a commit that adds it.

@@ -75,7 +81,7 @@ export {
assert,
// related utilities that aren't assertions
bareOrQuote as bare,
makeError,
bestMakeError as makeError,
note,
quote,
redacted,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
redacted,
X as redacted, // and deprecate `redacted` if possible
Fail as throwRedacted, // and deprecate `throwRedacted` if possible
Fail,
...

* @typedef {object} HiddenDetails
*
* Captures the arguments passed to the `details` template string tag.
* @typedef {{ template: TemplateStringsArray | string[], args: any[] }} DetailsParts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with the rename if the doc-comment here mentions that a DetailParts may hold redacted secrets, and so must not leak. I originally named it Hidden* to suggest that such care should be taken.

@@ -196,7 +198,11 @@ freeze(unredactedDetails);
export { unredactedDetails };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised to see that I exported unredactedDetails. Does not seem to be imported anywhere. If we cannot yet kill the (likely unused) export, could we at least deprecate it?

In any case, feel free not to address this quirk in this PR.

@erights
Copy link
Contributor

erights commented Jul 16, 2025

(I think the two CI errors were flakes, so restarted them. We'll see.)

payload: any,
spaces?: string | number,
): /** The declassified and quoted payload */ StringablePayload;
quote(value: any, spaces?: string | number): Stringable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s the third arg to JSON.stringify and I forgot we threaded it. It’s not a great idea to thread it.

@gibson042 gibson042 requested a review from erights August 2, 2025 17:45
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.

3 participants