Skip to content
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

Accept more Status codes in get_property. #237

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

alexsnaps
Copy link
Contributor

@alexsnaps alexsnaps commented Jun 11, 2024

Adds the missing Status enum variants...
We currently run into SerializationFailure when getting some attribute filter_state from Envoy... Today, this not only panics, but the error isn't even really recognized.
I'm not sure, given the current trait Context definition how to best deal with these gracefully tho? The default implementation are "just" Result::unwrap() ing the underlying host call.. So thinking that this is the best for now, wdyt?

@alexsnaps
Copy link
Contributor Author

@martijneken will you be managing this moving forward?

src/hostcalls.rs Outdated Show resolved Hide resolved
src/hostcalls.rs Outdated
Comment on lines 420 to 423
Status::NotFound | Status::Empty => Ok(None),
Status::SerializationFailure
| Status::BadArgument
| Status::BadExpression
| Status::Unimplemented => Err(status),
Copy link
Contributor Author

@alexsnaps alexsnaps Jun 20, 2024

Choose a reason for hiding this comment

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

This is a blind shot at trying to guess what "could" happen. I'm of the opinion that opening a seam to let the SDK user deal with them would be a more desirable way... if only "not the default" path so to keep the additional value of making it easier for implementers to test their host.

Unsure what the best approach would be? There could also be some global "flag" or something to get to a more lenient runtime behavior which lets the user take on the responsibility of dealing with "less standard" behaviors rather than having the SDK panic maybe?

If it is somewhere documented what valid Status every host method can return, I'm more than happy to generalize the pattern across the board.

Or would alternate behaviors be encouraged to be supported by using a tweaked copy of this SDK instead?

Copy link
Member

Choose a reason for hiding this comment

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

If it is somewhere documented what valid Status every host method can return, I'm more than happy to generalize the pattern across the board.

This pattern is already in this SDK, with some missing values (as you found out).

Or would alternate behaviors be encouraged to be supported by using a tweaked copy of this SDK instead?

What alternative behaviors do you have in mind, exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What alternative behaviors do you have in mind, exactly?

A path where the client code could gracefully deal with the "out of spec" (based on the above, that'd be any host behaving differently than the current Envoy codebase tho).
panic! in a crate is some radical thing to do. While I do see the advantage for this being the "default" behavior indeed, having some way to dealing gracefully with the Err would be nice I think... So unsure how to best enable that, wdyt? Would you agree that it'd be a nice to have? If so, how? make the unsafe method pub maybe and let someone deal with the entirety of the "problem"? Have some alternate method that gets you access to the raw Result? Possibly layering the code, where the "default public API" would call into the other pub fn, but deal explicitly with the Err behavior?

Copy link
Member

Choose a reason for hiding this comment

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

I understand what are you suggesting, but I'm still wondering who would ever use that and why... What host is expected to be knowingly out of spec and for what purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would use this, if only just on this very issue. Today we are stuck waiting on merge and release. So we need to fork in order to be able to make progress. I don't think (or say hope) any host would ever knowingly go out of spec... but the spec is loosely defined and requires one to look at Envoy if I go by how this was addressed. Envoy 1.20 (i.e. the proxy, the host - and probably more versions) crashed on SerializationFailure... All that to say that mistakes happen and hopefully also then get fixed, but until that happens it is, if only for us - that leverage this as part of bigger project then used by others - panicking is a very radical thing to do. So while I agree that hopefully we can find these issue easily while testing because of that very current behavior, being able to then also gracefully deal with them is desirable from a UX perspective.

Signed-off-by: Alex Snaps <alex@wcgw.dev>
@alexsnaps
Copy link
Contributor Author

Is there some next release on the horizon that could contain this (and the other changes, possibly more in the pipe)?

src/hostcalls.rs Outdated Show resolved Hide resolved
src/hostcalls.rs Show resolved Hide resolved
src/types.rs Outdated Show resolved Hide resolved
@PiotrSikora
Copy link
Member

Is there some next release on the horizon that could contain this (and the other changes, possibly more in the pipe)?

Yes! This or more likely next week.

src/hostcalls.rs Outdated Show resolved Hide resolved
…roperty

Signed-off-by: Alex Snaps <alex@wcgw.dev>
Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@PiotrSikora PiotrSikora changed the title Add all Status enum variants Accept more Status codes in get_property. Jul 13, 2024
@PiotrSikora PiotrSikora merged commit 442edc3 into proxy-wasm:main Jul 13, 2024
18 checks passed
antonengelhardt pushed a commit to antonengelhardt/proxy-wasm-rust-sdk that referenced this pull request Oct 23, 2024
Signed-off-by: Alex Snaps <alex@wcgw.dev>
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.

2 participants