Skip to content

feat(backend): GET organization settings#8367

Open
dmoerner wants to merge 1 commit intomainfrom
daniel/add-instance-org-settings-get
Open

feat(backend): GET organization settings#8367
dmoerner wants to merge 1 commit intomainfrom
daniel/add-instance-org-settings-get

Conversation

@dmoerner
Copy link
Copy Markdown
Contributor

Description

We recently added this BAPI endpoint because agents expect it to exist; they want to GET organization settings before doing a PATCH. In this PR we add support to the Javascript SDK as well.

I didn't bother with unit tests here because it would just be a thin mock.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

We recently added this BAPI endpoint because agents expect it to exist;
they want to GET organization settings before doing a PATCH. Add support
to the Javascript SDK as well.

I didn't bother with unit tests here because it would just be a thin
mock.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: 718b3b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Apr 21, 2026 1:24am

Request Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 21, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8367

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8367

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8367

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8367

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8367

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8367

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8367

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8367

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8367

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8367

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8367

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8367

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8367

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8367

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8367

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8367

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8367

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8367

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8367

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8367

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8367

commit: 718b3b8

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new method to the InstanceAPI class that retrieves organization settings from the backend instance. The change includes a changeset file documenting a minor version bump for @clerk/backend, and adds a getOrganizationSettings() public async method to InstanceApi.ts that performs a GET request to the '/instance/organization_settings' endpoint and returns an OrganizationSettings typed response.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(backend): GET organization settings' clearly and concisely describes the main change—adding a GET method for organization settings in the backend API.
Description check ✅ Passed The description explains that the PR adds JavaScript SDK support for a BAPI endpoint to GET organization settings, which directly relates to the changeset and code modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/backend/src/api/endpoints/InstanceApi.ts`:
- Around line 94-99: Add a unit test that exercises
InstanceApi.getOrganizationSettings(); specifically assert that it calls
this.request with method 'GET' and path equal to joinPaths(basePath,
'organization_settings') (or the resolved string) and that the generic return
type OrganizationSettings is expected; mock or spy on InstanceApi.request (or
the HTTP layer) to verify the method/path wiring and a mocked response is
returned, and add the test alongside other InstanceApi tests so the new endpoint
is covered before merge.
- Around line 94-99: The public method getOrganizationSettings in the
InstanceApi class lacks an explicit return type; update its signature to declare
the return type as Promise<OrganizationSettings> (matching the generic used in
this.request<OrganizationSettings>) so the method becomes explicitly typed and
conforms to the public API typing guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 65ffb5ed-9495-42d1-8926-63a5fc5996bf

📥 Commits

Reviewing files that changed from the base of the PR and between 683399a and 718b3b8.

📒 Files selected for processing (2)
  • .changeset/tiny-bobcats-train.md
  • packages/backend/src/api/endpoints/InstanceApi.ts

Comment on lines +94 to +99
public async getOrganizationSettings() {
return this.request<OrganizationSettings>({
method: 'GET',
path: joinPaths(basePath, 'organization_settings'),
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add tests for the new endpoint wrapper before merge.

Line 94 adds a new backend call path, but this PR has no test changes. Please add at least one test asserting method/path wiring for getOrganizationSettings().

As per coding guidelines: "**/*: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/backend/src/api/endpoints/InstanceApi.ts` around lines 94 - 99, Add
a unit test that exercises InstanceApi.getOrganizationSettings(); specifically
assert that it calls this.request with method 'GET' and path equal to
joinPaths(basePath, 'organization_settings') (or the resolved string) and that
the generic return type OrganizationSettings is expected; mock or spy on
InstanceApi.request (or the HTTP layer) to verify the method/path wiring and a
mocked response is returned, and add the test alongside other InstanceApi tests
so the new endpoint is covered before merge.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify public async methods missing explicit return types in this file
rg -nP --type=ts '^\s*public\s+async\s+\w+\([^)]*\)\s*\{' packages/backend/src/api/endpoints/InstanceApi.ts

Repository: clerk/javascript

Length of output: 343


🏁 Script executed:

cat -n packages/backend/src/api/endpoints/InstanceApi.ts | sed -n '85,110p'

Repository: clerk/javascript

Length of output: 895


🏁 Script executed:

cat -n packages/backend/src/api/endpoints/InstanceApi.ts | sed -n '1,95p' | tail -40

Repository: clerk/javascript

Length of output: 1421


🏁 Script executed:

fd -t f AbstractAPI.ts -o -t f AbstractAPI.tsx

Repository: clerk/javascript

Length of output: 176


🏁 Script executed:

rg -t ts 'class AbstractAPI' -l

Repository: clerk/javascript

Length of output: 109


🏁 Script executed:

cat packages/backend/src/api/endpoints/AbstractApi.ts

Repository: clerk/javascript

Length of output: 323


🏁 Script executed:

cat packages/backend/src/api/request.ts

Repository: clerk/javascript

Length of output: 8919


Add explicit return type to this public API method.

The getOrganizationSettings() method at line 94 is missing an explicit return type annotation. Per the coding guidelines, all public APIs must have explicit return types.

Proposed fix
-  public async getOrganizationSettings() {
+  public async getOrganizationSettings(): Promise<OrganizationSettings> {
     return this.request<OrganizationSettings>({
       method: 'GET',
       path: joinPaths(basePath, 'organization_settings'),
     });
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async getOrganizationSettings() {
return this.request<OrganizationSettings>({
method: 'GET',
path: joinPaths(basePath, 'organization_settings'),
});
}
public async getOrganizationSettings(): Promise<OrganizationSettings> {
return this.request<OrganizationSettings>({
method: 'GET',
path: joinPaths(basePath, 'organization_settings'),
});
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/backend/src/api/endpoints/InstanceApi.ts` around lines 94 - 99, The
public method getOrganizationSettings in the InstanceApi class lacks an explicit
return type; update its signature to declare the return type as
Promise<OrganizationSettings> (matching the generic used in
this.request<OrganizationSettings>) so the method becomes explicitly typed and
conforms to the public API typing guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant