Skip to content

Conversation

@nikithauc
Copy link
Contributor

@nikithauc nikithauc commented May 3, 2021

Certain workloads error out when an unexpected header is present in the request.

Example -

In case of LargeFileUploadTask in JS library, the upload is as follows:

client.api("UPLOAD_URL").put(chunk_to_be_uploaded)

The middleware appends request headers which are meant for the Graph API.

The solution for this is to add a check if the request URL is a Graph endpoint and not send headers to UPLOAD_URL.

Adding the headers only for Graph endpoints ignores the case where the developer might have their own test endpoints.
Example -
MGT uses a proxy sandbox environment
or

Support Custom Graph Endpoint graph.microsoft-ppe.com

microsoftgraph/microsoft-graph-toolkit#1053

I had a conversation with @darrelmiller about handling this case and he proposed that we allow developers to provide custom endpoints and update our conditions to modify request headers.

Copy link
Contributor

@MIchaelMainer MIchaelMainer left a comment

Choose a reason for hiding this comment

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

I think we apply retry-count header so we should add the retry handler to this.

As a global comment, lets add a change table at the bottom of these changed spec pages with date and a description of the change so that we can track the changes to spec over time without having to look at the commit history. This way, an SDK owner can understand at a glance whether there are new changes to a spec.

- Enable the developer to select a supported sovereign cloud using an enumerated list. Selecting the sovereign cloud should ensure that the AuthenticationProvider uses the appropriate Authentication Endpoint.
- Enable a developer to configure a HTTP proxy that will be used for outgoing requests.

- Enable a developer provide custom URLs or endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

Enable a developer provide custom URLs or endpoints.
Enable a developer to provide custom URLs or endpoints.

I think we should consider using the RequestContext mechanism to pass through the CustomUrls option through the middleware, in addition to an on individual request option where we can disable applying our headers.

Should this only be applicable to our default middleware or should the mechanism be accessible to custom middleware? Ideally custom middleware should be able to take advantage of this.

Do you have an example of a workload failing with an unexpected header? I can only think of OneDrive on redirection to a download/upload URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An example of a workload failing with an unexpected header - I got this error with Outlook large file upload too.

Copy link
Contributor

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

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

If we can, I think it would be great to add a code sample to demonstrate how the CustomURLs options will be used to be able to assess if this will affect the developer experience of the SDK user in any way.

@nikithauc nikithauc changed the title Introduce CustomURLs option Introduce CustomHosts option May 12, 2021
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Minor things but besides those, LGTM

- Enable a developer to provide custom hosts.
- `CustomHosts` option should be set on client creation.
- `CustomHosts` option should be made available in the `Context` so that it is available to the middleware during request processing.
- These URLs are different from the Graph service endpoints on the national clouds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- These URLs are different from the Graph service endpoints on the national clouds.
- These hostnames are different from the Graph service endpoints on the national clouds.

- If the request URL is a Graph service endpoint or a custom host provided by the developer, then append request headers or modify the request content.
- Else the middleware should delete request headers added by that middleware.
- Example of an workload error - [LargeFileUploadTask upload to OneDrive caused CORS error due `SDKVersion` telemetry header](https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/265)
- Provide capabilities to modify or update the `CustomURLs` option after the client creation.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Provide capabilities to modify or update the `CustomURLs` option after the client creation.
- Provide capabilities to modify or update the `CustomHosts` option after the client creation.

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.

5 participants