Skip to content

fix(auth): clear errors for missing BL_WORKSPACE/BL_API_KEY (ENG-2698)#326

Merged
mstolarzblaxelai merged 1 commit into
mainfrom
mstolarz/eng-2698-typescript-clear-auth-env-var-errors
May 29, 2026
Merged

fix(auth): clear errors for missing BL_WORKSPACE/BL_API_KEY (ENG-2698)#326
mstolarzblaxelai merged 1 commit into
mainfrom
mstolarz/eng-2698-typescript-clear-auth-env-var-errors

Conversation

@mstolarzblaxelai
Copy link
Copy Markdown
Contributor

@mstolarzblaxelai mstolarzblaxelai commented May 29, 2026

Fixes ENG-2698.

  • Missing or partial credentials silently coalesced to empty strings, so the SDK sent empty workspace/auth headers and the user hit the server's misleading "workspace is required" with no client-side guidance.
  • The SDK now fails fast with one clear error naming what to set (BL_API_KEY, BL_WORKSPACE, or bl login) before any request goes out.

Mirrors the Python fix (blaxel-ai/sdk-python#153).


Note

Adds fail-fast credential validation to the TypeScript SDK. When BL_API_KEY or BL_WORKSPACE are missing, authentication() now returns a MissingCredentials marker instead of an empty Credentials. A new assertCredentials() method called from both settings.headers and settings.authenticate() throws a CredentialsError with an actionable message naming the missing piece before any HTTP request goes out. Mirrors the Python SDK fix (sdk-python#153).

Written by Mendral for commit 3a82dc8.

Missing or partial credentials silently coalesced to empty strings, so the
SDK sent empty workspace/authorization headers and the user hit the server's
misleading "workspace is required" with no client-side guidance.

Fail fast with a clear, actionable error naming the missing piece
(BL_API_KEY / BL_WORKSPACE / `bl login`) before any request:
- authentication() returns a MissingCredentials marker instead of empty creds
- settings.headers and settings.authenticate() validate via assertCredentials
- forceUrl sessions (own headers) and sentry workspace tagging are unaffected

Mirrors the Python fix (sdk-python #153, ENG-2253).
Copy link
Copy Markdown
Contributor

@mendral-app mendral-app Bot left a comment

Choose a reason for hiding this comment

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

LGTM

The fail-fast logic is correct: MissingCredentials is caught before the workspace check, the workspace check catches partial configs (ApiKey without workspace), and sandbox forceUrl paths bypass settings.headers entirely and never call authenticate(). No security, correctness, or data-loss issues found.

Tag @mendral-app with feedback or questions. View session

@mstolarzblaxelai mstolarzblaxelai merged commit 06530fb into main May 29, 2026
27 of 29 checks passed
@mstolarzblaxelai mstolarzblaxelai deleted the mstolarz/eng-2698-typescript-clear-auth-env-var-errors branch May 29, 2026 00:34
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.

1 participant