Skip to content

chore: api convertion review#39851

Merged
ggazzo merged 7 commits intochore/apisfrom
chore/apis-review-fixes
Mar 25, 2026
Merged

chore: api convertion review#39851
ggazzo merged 7 commits intochore/apisfrom
chore/apis-review-fixes

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Mar 25, 2026

…ge parameter

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Added support for customizable HTTP status codes in API responses.
  • Bug Fixes

    • Improved API response validation and error messages for invalid requests across chat, custom status, and invite endpoints.
    • Enhanced message synchronization to provide accurate deletion records with proper timestamps.
  • Tests

    • Updated test assertions to match improved error message format.

- Replace bare `{ type: 'object' }` with `$ref IMessage` in response schemas where applicable
- Add `// relaxed:` comments to deliberately loose schemas explaining why
- Restore HTTP 202 status for commands.list when apps aren't loaded
- Restore explicit null check in commands.run/preview thread validation
- Add missing body validator to custom-user-status.delete endpoint
- Extract shared dmCreateAction factory for dm.create/im.create (DRY)
- Remove statusText from spotlight required fields (not always present)
- Fix sendInvitationEmailResponseSchema additionalProperties to false

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 25, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

⚠️ No Changeset found

Latest commit: b183dda

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cdfd010d-0f03-4ab3-9022-130a7fc542af

📥 Commits

Reviewing files that changed from the base of the PR and between 85d0087 and b183dda.

📒 Files selected for processing (11)
  • apps/meteor/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/helpers/getUserInfo.ts
  • apps/meteor/app/api/server/v1/chat.ts
  • apps/meteor/app/api/server/v1/commands.ts
  • apps/meteor/app/api/server/v1/custom-user-status.ts
  • apps/meteor/app/api/server/v1/im.ts
  • apps/meteor/app/api/server/v1/invites.ts
  • apps/meteor/app/api/server/v1/misc.ts
  • apps/meteor/app/api/server/v1/rooms.ts
  • apps/meteor/tests/end-to-end/api/custom-user-status.ts
  • packages/rest-typings/src/v1/chat.ts

Walkthrough

This pull request enhances API reliability and type safety by adding optional status code support to the core API success method, refining endpoint response schemas with more precise types, implementing request validation via AJV schemas, refactoring shared endpoint code, and updating corresponding REST type definitions.

Changes

Cohort / File(s) Summary
Core API Enhancement
apps/meteor/app/api/server/ApiClass.ts
Extended success method to accept optional statusCode parameter with SuccessStatusCodes type, replacing hardcoded 200 default. Method signature updated to support dynamic HTTP response codes.
API Endpoint Schemas & Response Updates
apps/meteor/app/api/server/v1/chat.ts, apps/meteor/app/api/server/v1/commands.ts, apps/meteor/app/api/server/v1/im.ts, apps/meteor/app/api/server/v1/invites.ts, apps/meteor/app/api/server/v1/misc.ts, apps/meteor/app/api/server/v1/rooms.ts
Refined AJV schemas to use #/components/schemas/IMessage references instead of generic objects, disallowed additional properties where appropriate, updated status codes (202 for commands early return), and added clarifying inline comments. Refactored im.ts to extract shared endpoint definitions for dm.create and im.create.
Request Validation Schema
apps/meteor/app/api/server/v1/custom-user-status.ts
Added AJV validation schema (isCustomUserStatusDeleteProps) for request body requiring non-empty customUserStatusId string. Removed corresponding manual runtime validation check in favor of declarative schema validation.
Type Definitions & Documentation
packages/rest-typings/src/v1/chat.ts, apps/meteor/app/api/server/helpers/getUserInfo.ts
Updated chat.syncMessages response type: result.deleted field narrowed from IMessage[] to array of objects containing only _id and _deletedAt. Added inline comment documenting type casting behavior in getUserInfo.
Test Updates
apps/meteor/tests/end-to-end/api/custom-user-status.ts
Updated error message assertion for missing customUserStatusId to expect AJV validation format (must have required property 'customUserStatusId') instead of prior custom message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Suggested labels

type: chore


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.

❤️ Share

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.60%. Comparing base (85d0087) to head (b183dda).
⚠️ Report is 1 commits behind head on chore/apis.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           chore/apis   #39851      +/-   ##
==============================================
- Coverage       70.60%   70.60%   -0.01%     
==============================================
  Files            3256     3256              
  Lines          115791   115792       +1     
  Branches        21043    21053      +10     
==============================================
- Hits            81753    81750       -3     
- Misses          31976    31979       +3     
- Partials         2062     2063       +1     
Flag Coverage Δ
unit 71.14% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ggazzo and others added 6 commits March 25, 2026 09:59
- Update success method in APIClass to accept an optional status code.
- Modify commands.list response to utilize the new success method with a 202 status code when apps are not loaded.
- Refactor thread validation checks in commands.run and commands.preview for consistency.
Deleted messages only contain `_id` and `_deletedAt`, not full IMessage
objects. The response schema was incorrectly referencing IMessage, causing
validation to fail with "must have required property 'rid'".

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Updated the response schema to clarify that deleted messages only include `_id` and `_deletedAt` properties, ensuring proper validation and alignment with the expected structure.
…se ISO string format

Modified the response schema for deleted messages to ensure `_deletedAt` is returned as an ISO string instead of a Date object, improving consistency and compatibility with the API response structure.
…om-user-status endpoint

Revised the error response for the custom-user-status API to provide a clearer message indicating that the 'customUserStatusId' parameter is required, enhancing the clarity of API validation feedback.
@ggazzo ggazzo marked this pull request as ready for review March 25, 2026 15:23
@ggazzo ggazzo requested review from a team as code owners March 25, 2026 15:23
@ggazzo ggazzo merged commit 007dd57 into chore/apis Mar 25, 2026
41 of 43 checks passed
@ggazzo ggazzo deleted the chore/apis-review-fixes branch March 25, 2026 15:23
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/app/api/server/v1/commands.ts">

<violation number="1" location="apps/meteor/app/api/server/v1/commands.ts:158">
P2: This branch returns HTTP 202, but `commands.list` only defines schemas for 200/400/401. Use a declared status code or add a 202 response schema to keep the endpoint contract consistent.</violation>
</file>

<file name="apps/meteor/app/api/server/v1/chat.ts">

<violation number="1" location="apps/meteor/app/api/server/v1/chat.ts:678">
P2: Do not default missing `_deletedAt` to the current time in sync payloads; this returns incorrect deletion metadata.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

total: 0,
success: true as const,
},
202,
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 25, 2026

Choose a reason for hiding this comment

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

P2: This branch returns HTTP 202, but commands.list only defines schemas for 200/400/401. Use a declared status code or add a 202 response schema to keep the endpoint contract consistent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/app/api/server/v1/commands.ts, line 158:

<comment>This branch returns HTTP 202, but `commands.list` only defines schemas for 200/400/401. Use a declared status code or add a 202 response schema to keep the endpoint contract consistent.</comment>

<file context>
@@ -146,13 +146,17 @@ const commandsEndpoints = API.v1
+						total: 0,
+						success: true as const,
+					},
+					202,
+				);
 			}
</file context>
Suggested change
202,
200,
Fix with Cubic

? result.deleted.map((msg) => ({
_id: msg._id,
_deletedAt:
'_deletedAt' in msg && msg._deletedAt instanceof Date ? msg._deletedAt.toISOString() : new Date().toISOString(),
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 25, 2026

Choose a reason for hiding this comment

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

P2: Do not default missing _deletedAt to the current time in sync payloads; this returns incorrect deletion metadata.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/app/api/server/v1/chat.ts, line 678:

<comment>Do not default missing `_deletedAt` to the current time in sync payloads; this returns incorrect deletion metadata.</comment>

<file context>
@@ -655,7 +670,14 @@ const chatEndpoints = API.v1
+							? result.deleted.map((msg) => ({
+									_id: msg._id,
+									_deletedAt:
+										'_deletedAt' in msg && msg._deletedAt instanceof Date ? msg._deletedAt.toISOString() : new Date().toISOString(),
+								}))
+							: [],
</file context>
Fix with Cubic

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant