Skip to content

feat: add user-agent prefix input#145

Open
goanpeca wants to merge 9 commits into
mainfrom
feat/issue-106-sdk-parity
Open

feat: add user-agent prefix input#145
goanpeca wants to merge 9 commits into
mainfrom
feat/issue-106-sdk-parity

Conversation

@goanpeca

@goanpeca goanpeca commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a user-agent-prefix input to action.yml, README, and the generated action bundle.
  • Thread the optional prefix through parsed inputs into the SDK B2Client userAgent, preserving the default b2-github-action/<version> token and treating blank prefixes as unset.
  • Validate prefixes before client construction with a 128-byte UTF-8 limit and visible ASCII-only policy, rejecting control characters, DEL, tab, non-ASCII/surrogate payloads, spaces, and oversized values with parser errors.
  • Measure prefix byte length with Buffer.byteLength(value, 'utf8') to avoid allocating encoded bytes during validation.
  • Document the final User-Agent format, accepted character contract, changelog entry, and a copyable repository/workflow traceability example.
  • Cover configured, absent, blank, and invalid prefixes in tests, and rebuild 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 build
  • pre-commit hook: lint, release provenance, typecheck, vitest, ncc build, cspell
  • pre-push hook: vitest --coverage

Follow-up notes

Copilot AI review requested due to automatic review settings July 8, 2026 13:07
@goanpeca goanpeca added this to the v1.2.0 milestone Jul 8, 2026
@goanpeca goanpeca added enhancement New feature or request sdk-parity SDK capability not yet exposed by the action labels Jul 8, 2026
@goanpeca goanpeca self-assigned this Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-prefix in action.yml and documents it in README.md.
  • Parses and validates the new input (rejecting control characters) and threads it through to buildClient.
  • Updates buildClient to prepend the prefix to the action User-Agent token, and adds/updates unit tests and dist/ 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.

Comment thread __tests__/main.test.ts
Copilot AI review requested due to automatic review settings July 8, 2026 13:14
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Comment thread README.md Outdated
Comment thread __tests__/main.test.ts
Copilot AI review requested due to automatic review settings July 8, 2026 13:18
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Comment thread README.md Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Comment thread src/client.ts Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 13:26
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 13:32
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 13:42
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Comment thread src/inputs.ts Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 13:48
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated no new comments.

@goanpeca
goanpeca marked this pull request as ready for review July 8, 2026 13:53
Copilot AI review requested due to automatic review settings July 8, 2026 23:15
@goanpeca
goanpeca force-pushed the feat/issue-106-sdk-parity branch from 0c817e6 to 5f72538 Compare July 8, 2026 23:15
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Build artifact for this PR: build.tar.gz (valid 1 hour)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Comment thread src/inputs.ts
* transport and return the prefix when it is present.
*/
export function parseUserAgentPrefix(value: string | undefined): string | undefined {
if (value === undefined) return undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sdk-parity SDK capability not yet exposed by the action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants