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

Ignore invalid range in blob download #2462

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

cnaj
Copy link
Contributor

@cnaj cnaj commented Sep 4, 2024

Fix #2458, based on #2461

I'm not sure how to provoke an invalid range header in the unit tests; @blueww can you give me a hint?

@cnaj
Copy link
Contributor Author

cnaj commented Sep 5, 2024

@microsoft-github-policy-service agree company="corpuls"

@blueww
Copy link
Member

blueww commented Sep 6, 2024

@EmmaZhu

Do you have any idea how to input a invalid range header like "0--1" in download blob API by JS SDK (in Azurite test)?

@EmmaZhu
Copy link
Member

EmmaZhu commented Sep 10, 2024

Following is sample to set a customized header to a blobClient instance:

// Define a PipelinePolicy to set a customized header
export const injectorPolicyName = "injectorPolicy";

export function injectorPolicy(): PipelinePolicy {
  return {
    name: injectorPolicyName,
    async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {
      request.headers.set('headername', `headervalue`);
      return next(request);
    },
  };
}
    // Insert the policy to pipeline in blobClient's contenxt
    const injector = injectorPolicy();

    const pipeline: Pipeline = (blobClient as any).storageClientContext.pipeline;
    pipeline.addPolicy(injector, {phase: 'Retry'});

   // code against blobClient

@blueww
Copy link
Member

blueww commented Sep 11, 2024

@cnaj
Would you please look at the sample code from Emma for how to add customized header when send request with JS storage SDK, and follow up it to add the test case?

@cnaj
Copy link
Contributor Author

cnaj commented Sep 12, 2024

I'm still trying to figure out how to apply @EmmaZhu's suggestion. For instance, there is no pipeline property on blobClient.storageClientContext, as far as I can see in the debugger. Also, this is an undocumented feature for which I don't have enough information... Could you please clarify?

@blueww
Copy link
Member

blueww commented Sep 18, 2024

@EmmaZhu
Would you please look at the above comments, and share the info that @cnaj needed?
Thanks!

@gaul
Copy link
Contributor

gaul commented Jan 13, 2025

@EmmaZhu is there any way to unblock this PR? I have a duplicate one open.

@blueww
Copy link
Member

blueww commented Jan 13, 2025

@gaul , @cnaj

This is a sample azurite test case which use "addpolicy" to add a customized policy to change to request send from storage js SDK.
Would you please refer it for how to apply the test case?

serviceClientForOPTIONS.pipeline.addPolicy(customPolicy);

The customized policy class is defined in https://github.com/Azure/Azurite/blob/main/tests/blob/RequestPolicy/OPTIONSRequestPolicyFactory.ts

@cnaj
Copy link
Contributor Author

cnaj commented Jan 13, 2025

Thank you @blueww, this hint pointed me into the right direction. I've added an additional test as a sanity check for the new RangePolicy.

@blueww blueww merged commit 26de24b into Azure:main Jan 14, 2025
34 checks passed
@blueww
Copy link
Member

blueww commented Jan 14, 2025

Thanks @cnaj!
The PR looks good for me, and I have merged it.

@cnaj cnaj deleted the 2458-blob-ignore-invalid-range branch January 14, 2025 13:06
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.

Empty blob access error using Java SDK
4 participants