Skip to content

Commit 1227210

Browse files
haraldschillyclaude
andcommitted
server/conat/api: include project_id in system.test response
For project-scoped API keys, the hub endpoint's system.test() method was only returning account_id (empty string), making it impossible for callers to distinguish project-scoped keys from invalid keys. Now the method accepts and returns both account_id and project_id depending on the key scope. This allows the Python cocalc-api client to properly identify key scope during discovery, matching the behavior of the project endpoint's system.test() implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ab4ab26 commit 1227210

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/packages/server/conat/api/system.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ export function ping() {
2020

2121
export async function test({
2222
account_id,
23-
}: { account_id?: string } = {}) {
23+
project_id,
24+
}: { account_id?: string; project_id?: string } = {}) {
2425
// Return API key scope information and server time
25-
// The authFirst decorator determines the scope from the API key and injects account_id.
26-
const response: { account_id: string; server_time: number } = {
27-
account_id: account_id ?? "",
26+
// The authFirst decorator determines the scope from the API key and injects either
27+
// account_id (for account-scoped keys) or project_id (for project-scoped keys).
28+
const response: {
29+
account_id?: string;
30+
project_id?: string;
31+
server_time: number;
32+
} = {
2833
server_time: Date.now(),
2934
};
35+
if (account_id) {
36+
response.account_id = account_id;
37+
}
38+
if (project_id) {
39+
response.project_id = project_id;
40+
}
3041
return response;
3142
}
3243

0 commit comments

Comments
 (0)