← 输入框|github.com|刷新
Skip to content

fix(samples): pass headers in method options and add upload CLI argument check - #4058

Open
reginaldalfret wants to merge 1 commit into
googleapis:mainfrom
reginaldalfret:fix/youtube-samples-options
Open

reginaldalfret wants to merge 1 commit into
googleapis:mainfrom
reginaldalfret:fix/youtube-samples-options

Conversation

@reginaldalfret

Copy link
Copy Markdown

Summary

This PR improves the YouTube API code samples in samples/youtube/:

  1. Method Options Separation (samples/youtube/playlist.js): In getPlaylistData(), passes the conditional ETag request headers via the second MethodOptions parameter ({ headers }) rather than mixed into the API query parameters object (params). This follows the library contract and ensures custom headers are cleanly applied as request options.
  2. CLI Argument Guard (samples/youtube/upload.js): Adds argument validation and usage instructions when running node upload.js directly without specifying a file path, preventing unhandled TypeError exceptions from fs.statSync(undefined).

Testing

  • Validated with samples/test/test.samples.youtube.js (all 3 tests passing).

…ent check

In samples/youtube/playlist.js, pass custom ETag headers in the second MethodOptions parameter rather than mixed into API query params to adhere to the client signature contract.

In samples/youtube/upload.js, add validation and usage guidance when executed directly without a file path argument.

Validated with samples/test/test.samples.youtube.js.

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
@reginaldalfret
reginaldalfret requested a review from a team as a code owner October 29, 2026 01:19
@product-auto-label product-auto-label Bot added size: s Pull request size is small. samples Issues that are directly related to samples. labels Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant