Skip to content

Fix uploadFile stream error handling, public type exports, and SDK parity - #140

Merged
AHarmlessPyro merged 4 commits into
mainfrom
fix/sdk-audit-improvements
Nov 10, 2026
Merged

AHarmlessPyro merged 4 commits into
mainfrom
fix/sdk-audit-improvements

Conversation

@shrisukhani

@shrisukhani shrisukhani commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • SessionsService.uploadFile: Avoid throwing synchronously inside fileStream.on("error") (which caused an uncaught exception in Node.js); check file readability with fs.access(fileInput, R_OK) and reject cleanly with HyperbrowserError on stream/form errors.
  • NON_RETRYABLE_ERROR_CODES: Add all 6 non-retryable secret error codes (SECRETS_ADMIN_REQUIRED, SECRETS_NOT_CONFIGURED, SECRET_KEY_UNAVAILABLE, SECRET_DECRYPT_FAILED, SECRET_ENVELOPE_INVALID, SECRET_VALUE_INVALID) matching python-sdk.
  • SandboxHandle: Add startupSecrets getter matching python-sdk's sandbox.startup_secrets property and remove unused private applyRuntimeSession.
  • Public type exports (src/types/index.ts, src/types/session.ts): Export all web/crawl types, missing scrape/batch-scrape types, and SessionRecording / CreateSessionProfile; add persistNetworkCache to SessionProfile and duration / proxyDataConsumed to Session.
  • Vaults/Secrets & Tools: Validate customerKey upfront in VaultsService.unwrap, SecretsService.unwrap, and SecretsService.rewrap before making network calls; verify customerKey.wrap() returns a non-empty string; shallow-clone params in WebsiteExtractTool.runnable instead of mutating params.schema in place.

Testing

  • yarn build
  • yarn lint
  • yarn test (unit + integration suites)

Note

Medium Risk
Changes session file upload behavior, secret/vault preflight validation, and which API errors are retried—mostly hardening, but callers may see different errors or fewer retries on 503 secret failures.

Overview
Bumps @hyperbrowser/sdk to 1.5.1 and aligns behavior with the Python SDK in several hot paths.

SessionsService.uploadFile now checks path readability with fs.access, attaches FormData/stream error listeners, aborts in-flight uploads on read failures, and races the request against stream errors so Node no longer throws uncaught exceptions from piping a broken body.

Customer secrets/vaults gain shared assertCustomerKeys / wrapEnvelope helpers: invalid keys are rejected before API calls, empty key lists are allowed only where nothing needs a key, and wrap() must return a non-empty string. SecretsService / VaultsService use these on unwrap/rewrap/upload.

BaseService treats six additional secret-related API codes as non-retryable (matching Python), even on 503. SandboxHandle exposes startupSecrets and drops unused applyRuntimeSession.

Public types export web crawl, batch scrape, SessionRecording, CreateSessionProfile, and session fields (persistNetworkCache, duration, proxyDataConsumed). WebsiteExtractTool.runnable parses a string schema on a shallow clone instead of mutating caller params.

Unit tests cover upload edge cases, secret validation, retry codes, and startupSecrets.

Reviewed by Cursor Bugbot for commit e122fda. Bugbot is set up for automated code reviews on this repo. Configure here.

@AHarmlessPyro

AHarmlessPyro commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

shrisukhani and others added 3 commits November 10, 2026 04:05
- uploadFile: attach the FormData/stream error listener for path, stream
  and Buffer inputs (stream inputs could still crash the process), abort
  the in-flight request when the body fails, and never destroy a stream
  the caller owns.
- Tests pipe the body like node-fetch does, so they reproduce the
  uncaught exception on the previous code.
- Up-front customer key checks still validate each key but allow an
  empty list; customerKeyFor rejects it only when a key is needed.
- startupSecrets returns a copy, like exposedPorts.
- Mark enableWebglFingerprinting as deprecated (the server ignores it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AHarmlessPyro
AHarmlessPyro added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit afbdf9e Nov 10, 2026
3 checks passed
@AHarmlessPyro
AHarmlessPyro deleted the fix/sdk-audit-improvements branch November 10, 2026 20:25
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.

2 participants