fix(apps): handle multiple results returned from /apps/installed endpoint#39554
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughAdds handling in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/meteor/client/apps/orchestrator.ts (2)
52-52: Minor: Missing space afterifkeyword.For consistency with the rest of the codebase (see line 55, 75, etc.), add a space between
ifand(.✏️ Formatting fix
- if(Array.isArray(result)){ + if (Array.isArray(result)) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/client/apps/orchestrator.ts` at line 52, The if statement uses no space after the keyword ("if(Array.isArray(result))"); update it to match project style by adding a space after if so it reads like "if (Array.isArray(result))", keeping the same condition and surrounding logic that references result and Array.isArray.
55-58: Stale TODO comment should be removed or updated.Lines 52-54 now handle the "multiple results" case by extracting
result[0]?.appsfrom array responses. The TODO at line 56 describing this exact scenario appears to be addressed by this change and should be removed for clarity.🧹 Proposed cleanup
if ('apps' in result) { - // TODO: chapter day: multiple results are returned, but we only need one return result.apps as App[]; }As per coding guidelines: "Avoid code comments in the implementation" for TypeScript files.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/client/apps/orchestrator.ts` around lines 55 - 58, Remove the stale TODO comment about "multiple results" in the block that checks "if ('apps' in result)" since the array-response case is already handled elsewhere by using result[0]?.apps; update or delete the comment to avoid confusion and comply with the guideline to avoid inline implementation comments in TypeScript files (refer to the result variable and the result[0]?.apps extraction when locating the related logic in orchestrator.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/meteor/client/apps/orchestrator.ts`:
- Line 52: The if statement uses no space after the keyword
("if(Array.isArray(result))"); update it to match project style by adding a
space after if so it reads like "if (Array.isArray(result))", keeping the same
condition and surrounding logic that references result and Array.isArray.
- Around line 55-58: Remove the stale TODO comment about "multiple results" in
the block that checks "if ('apps' in result)" since the array-response case is
already handled elsewhere by using result[0]?.apps; update or delete the comment
to avoid confusion and comply with the guideline to avoid inline implementation
comments in TypeScript files (refer to the result variable and the
result[0]?.apps extraction when locating the related logic in orchestrator.ts).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ed98dc90-5fd7-44c0-952b-b149bf082627
📒 Files selected for processing (1)
apps/meteor/client/apps/orchestrator.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/client/apps/orchestrator.ts
🧠 Learnings (3)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.
Applied to files:
apps/meteor/client/apps/orchestrator.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/client/apps/orchestrator.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/client/apps/orchestrator.ts
🔇 Additional comments (1)
apps/meteor/client/apps/orchestrator.ts (1)
52-54: Type mismatch: REST typings don't include array response.The REST type definition at
packages/rest-typings/src/apps/index.ts:189-191declares/apps/installedreturns{ success: true; apps: App[] } | { success: false; error: string }, not an array. This runtime handling contradicts the typed contract.Consider updating the REST typings to reflect the actual clustered response shape, or add a type assertion with a comment explaining the discrepancy. Without updating types, TypeScript may flag
Array.isArray(result)as always false.[raise_major_issue, request_verification]
#!/bin/bash # Verify REST typing for /apps/installed endpoint rg -n "'/apps/installed'" --type ts -A 3
|
Hi @dougfabris, could you please take a look at this PR when you have time? I’d really appreciate your review. Thanks! |
Description
The
/apps/installedendpoint may return multiple results whenincludeClusterStatus=true, particularly in clustered environments.The current implementation assumes that the response always contains a single object with an
appsproperty. However, if the API returns multiple results (for example, responses from different nodes in a cluster), the existing logic may fail and throw an error.This change ensures that when the response is an array, the client safely uses the first result to retrieve the list of installed apps.
Changes
/apps/installedNotes
This change addresses the TODO comment in
orchestrator.tsregarding multiple results returned from the/apps/installedAPI.Summary by CodeRabbit
Bug Fixes