feat: add user-agent prefix input#145
Conversation
|
Build artifact for this PR: |
There was a problem hiding this comment.
Pull request overview
Adds a new optional user-agent-prefix input so workflows can prepend a traceable marker to the action’s User-Agent string while keeping the action’s default b2-github-action/<version> token, including validation to prevent HTTP header control characters and rebuilding dist/.
Changes:
- Introduces
user-agent-prefixinaction.ymland documents it inREADME.md. - Parses and validates the new input (rejecting control characters) and threads it through to
buildClient. - Updates
buildClientto prepend the prefix to the action User-Agent token, and adds/updates unit tests anddist/output.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main.ts | Conditionally passes userAgentPrefix into client construction only when provided. |
| src/inputs.ts | Adds userAgentPrefix to parsed inputs and validates it for HTTP-header safety. |
| src/client.ts | Builds the SDK userAgent string with optional prefix + action token. |
| action.yml | Exposes the new user-agent-prefix input to action consumers. |
| README.md | Documents the new input and warns not to include secrets. |
| tests/inputs.test.ts | Tests parsing and rejection of control characters for the new input. |
| tests/main.test.ts | Tests that buildClient receives userAgentPrefix when present. |
| tests/client.test.ts | Tests that the constructed SDK options include the prefixed User-Agent. |
| tests/_parsed-inputs.ts | Updates the parsed-inputs fixture to include userAgentPrefix. |
| dist/index.js | Rebuilt distribution output reflecting the new input and User-Agent behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Build artifact for this PR: |
|
Build artifact for this PR: |
|
Build artifact for this PR: |
|
Build artifact for this PR: |
|
Build artifact for this PR: |
|
Build artifact for this PR: |
|
Build artifact for this PR: |
0c817e6 to
5f72538
Compare
|
Build artifact for this PR: |
| * transport and return the prefix when it is present. | ||
| */ | ||
| export function parseUserAgentPrefix(value: string | undefined): string | undefined { | ||
| if (value === undefined) return undefined |
Summary
user-agent-prefixinput toaction.yml, README, and the generated action bundle.B2ClientuserAgent, preserving the defaultb2-github-action/<version>token and treating blank prefixes as unset.Buffer.byteLength(value, 'utf8')to avoid allocating encoded bytes during validation.dist.Linked issue
Tests run
/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm docs:check-action-yml/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm docs:lint/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm cspell README.md/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm vitest run __tests__/inputs.test.ts __tests__/client.test.ts __tests__/main.test.ts/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm vitest run __tests__/inputs.test.ts/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm lint/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm typecheck/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm run docs/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm test/Users/gpenacastellanos/miniforge3/condabin/conda run -n b2-action-issue-106 pnpm buildFollow-up notes