Skip to content

FCE-2044 validate credentials at client creation#271

Open
czerwiukk wants to merge 5 commits into
mainfrom
FCE-2044/sdk-clients-should-fail-fast
Open

FCE-2044 validate credentials at client creation#271
czerwiukk wants to merge 5 commits into
mainfrom
FCE-2044/sdk-clients-should-fail-fast

Conversation

@czerwiukk
Copy link
Copy Markdown
Member

Description

Adds credentials validation to the preferred way of creating the client.
There is also a separate checkCredentials method if someone needs to create the client synchronously.

Motivation and Context

The SDK client should fail fast when misconfigured.

Documentation impact

  • Documentation update required
  • Documentation updated in another PR
  • No documentation update required

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)

@linear
Copy link
Copy Markdown

linear Bot commented May 22, 2026

FCE-2044

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds fail-fast configuration/credential validation paths for FishjamClient, introducing an async factory to verify credentials against the backend and a reusable config-validation helper, with accompanying test coverage.

Changes:

  • Added validateFishjamConfig and MissingManagementTokenException to validate required config fields at construction time.
  • Introduced FishjamClient.create() (async factory) and checkCredentials() to validate credentials via a backend call.
  • Added new Vitest coverage for sync config validation and mocked credential-check behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/js-server-sdk/tests/config-validation.test.ts Adds tests for constructor config validation and mocked backend credential checks via getAllRooms.
packages/js-server-sdk/src/utils.ts Introduces validateFishjamConfig to enforce presence of fishjamId and managementToken.
packages/js-server-sdk/src/exceptions/index.ts Adds MissingManagementTokenException for missing/empty management token config.
packages/js-server-sdk/src/client.ts Validates config in constructor; adds create() async factory and checkCredentials() method with updated JSDoc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/js-server-sdk/src/client.ts Outdated
* Async factory. Constructs a client and verifies that the provided
* `fishjamId` and `managementToken` are accepted by the Fishjam backend.
*
* Throws {@link InvalidFishjamConfigException} for malformed config,
Comment thread packages/js-server-sdk/src/client.ts Outdated
Comment on lines +36 to +37
* Fishjam backend. Use {@link FishjamClient.create} or
* {@link FishjamClient.checkCredentials} to verify them at construction time.
Comment on lines +93 to +101
* Verifies the configured credentials by making a single lightweight
* call to the Fishjam backend. Resolves on success, otherwise throws the
* same exception types thrown by other client methods (notably
* {@link UnauthorizedException} and {@link FishjamNotFoundException}).
*/
async checkCredentials(): Promise<void> {
try {
await this.roomApi.getAllRooms();
} catch (error) {
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