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

fix: Handle 406 http errors #57

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

haleemur
Copy link
Contributor

@haleemur haleemur commented Mar 25, 2024

We have been noticing 406 errors when running discovery, specifically on the .../describe endpoint.

requests.exceptions.HTTPError: 406 Client Error: CustomNotAcceptable for url: https://XXX.salesforce.com/services/data/v53.0/sobjects/XXX/describe

This MR adds error handling for this. The error code 406 is new to me, so I wanted to look up what that meant. Salesforce's error codes page does not even document it. https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm

From the various pieces of literature I've read, it seems that the way to correct this issue is to set one of the accept, accept-encoding & accept-language appropriately, however we have not been providing alternate values for these headers and the error is encountered intermittently.

My best guess is that a separate issue occurs, but salesforce does not report the actual error, and instead we are returned a 406, which is not very meaningful. To recover from these failures, we simply rerun the taps. However, adding a retry specific to this error code seems like a better approach and it will benefit the wider meltano / singer community.

MDN defines 406 as

The HyperText Transfer Protocol (HTTP) 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers, and that the server is unwilling to supply a default representation.

In practice, this error is very rarely used. Instead of responding using this error code, which would be cryptic for the end user and difficult to fix, servers ignore the relevant header and serve an actual page to the user. It is assumed that even if the user won't be completely happy, they will prefer this to an error code.

If a server returns such an error status, the body of the message should contain the list of the available representations of the resources, allowing the user to choose among them.

source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406

Found the following through more google searches:

https://zendenwebdesign.com/causes-and-fixes-for-406-error-not-acceptable/

and also, in the salesforce community forums, users reported seeing this type of error:
https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A93GsSAJ

Related Issues

@haleemur haleemur changed the title Handle 406 errors fix: Handle 406 http errors Mar 25, 2024
Copy link
Member

@edgarrmondragon edgarrmondragon 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 @haleemur.

@edgarrmondragon edgarrmondragon merged commit 64e05a4 into MeltanoLabs:main Mar 27, 2024
1 check passed
nezd pushed a commit to dext/tap-salesforce that referenced this pull request Sep 26, 2024
We have been noticing 406 errors when running discovery, specifically on
the `.../describe` endpoint.

```
requests.exceptions.HTTPError: 406 Client Error: CustomNotAcceptable for url: https://XXX.salesforce.com/services/data/v53.0/sobjects/XXX/describe
```

This MR adds error handling for this. The error code 406 is new to me,
so I wanted to look up what that meant. Salesforce's error codes page
does not even document it.
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm

From the various pieces of literature I've read, it seems that the way
to correct this issue is to set one of the accept, accept-encoding &
accept-language appropriately, however we have not been providing
alternate values for these headers and the error is encountered
intermittently.

My best guess is that a separate issue occurs, but salesforce does not
report the actual error, and instead we are returned a 406, which is not
very meaningful. To recover from these failures, we simply rerun the
taps. However, adding a retry specific to this error code seems like a
better approach and it will benefit the wider meltano / singer
community.

MDN defines 406 as

>The HyperText Transfer Protocol (HTTP) 406 Not Acceptable client error
response code indicates that the server cannot produce a response
matching the list of acceptable values defined in the request's
proactive content negotiation headers, and that the server is unwilling
to supply a default representation.
>
>In practice, this error is very rarely used. Instead of responding
using this error code, which would be cryptic for the end user and
difficult to fix, servers ignore the relevant header and serve an actual
page to the user. It is assumed that even if the user won't be
completely happy, they will prefer this to an error code.
>
>If a server returns such an error status, the body of the message
should contain the list of the available representations of the
resources, allowing the user to choose among them.

source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406

Found the following through more google searches:


https://zendenwebdesign.com/causes-and-fixes-for-406-error-not-acceptable/

and also, in the salesforce community forums, users reported seeing this
type of error:

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A93GsSAJ


# Related Issues

- closes: MeltanoLabs#58
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.

HTTPError 406 CustomNotAcceptable encountered intermittently
2 participants