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

Throw non-JSON responses as errors #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seanami
Copy link

@seanami seanami commented Mar 20, 2023

I'm working to get the { redirect: 'manual' } option working in my codebase, so that I can detect when a middleman is redirecting my requests to my API server and respond accordingly.

Currently, I'm finding that when I include this option and make a request that redirects, I get a SyntaxError thrown as a result. This is coming from r.json() since the browser returns a response object with type: 'opaqueredirect' which isn't a JSON string.

My proposed solution is to catch errors from the JSON conversion and throw the original response object as an error in that case, which works for my use case. I'm also open to other ways of making this original response object accessible to the caller, though.

I had trouble getting the integration tests to run, so that I could extend them and implement a test case for this. Trying to run ./scripts/gen-server-proto.sh after making a change to the server to add an endpoint that redirects, I get:

--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC

See https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code for more information.

@google-cla
Copy link

google-cla bot commented Mar 20, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

None yet

1 participant