Skip to content

chore: convert apis#39779

Merged
ggazzo merged 13 commits intochore/apisfrom
chore/apis-2
Mar 23, 2026
Merged

chore: convert apis#39779
ggazzo merged 13 commits intochore/apisfrom
chore/apis-2

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Mar 20, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved error handling consistency across API endpoints with standardized validation and response schemas
    • Fixed commands.list endpoint response structure when applications are not loaded
  • Documentation

    • Added guidelines for API endpoint migration best practices and type augmentation patterns

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 20, 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 targeting the wrong base branch. It should target 8.4.0, but it targets 8.3.0

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 20, 2026

⚠️ No Changeset found

Latest commit: bc60cf4

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 20, 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: 79f4ac77-0e7f-45ff-a5fe-1c897842d025

📥 Commits

Reviewing files that changed from the base of the PR and between 573e8e7 and bc60cf4.

📒 Files selected for processing (7)
  • 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/misc.ts
  • apps/meteor/tests/end-to-end/api/commands.ts
  • docs/api-endpoint-migration.md
  • packages/rest-typings/src/v1/commands.ts

Walkthrough

Refactored multiple REST API endpoints to use fluent chainable API pattern with AJV schema validation, replacing legacy API.v1.addRoute() registrations. Updated error responses, removed deprecated type definitions, and added documentation guidelines for endpoint migrations.

Changes

Cohort / File(s) Summary
API Endpoint Refactoring
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/misc.ts
Migrated endpoints from legacy API.v1.addRoute() to fluent chainable pattern with explicit AJV schemas for query/body/response validation. Updated error responses and standardized 200/400/401/403 status handling. Key changes include: chat.react and chat.reportMessage with action handlers, commands.list with paginated response schema, consolidated dm/im endpoints with typed validation, and shield.svg with structured response object.
Type Definitions
packages/rest-typings/src/v1/commands.ts
Removed exported endpoint type declaration for /v1/commands.list including related type imports for SlashCommand, PaginatedRequest, and PaginatedResult.
Test Updates
apps/meteor/tests/end-to-end/api/commands.ts
Updated authorization failure assertion for commands.run to expect 'unauthorized' error instead of 'Not allowed'.
Documentation
docs/api-endpoint-migration.md
Added migration guidelines clarifying augmentation scope limited to apps/meteor, type definition retention requirements, and as const usage for endpoint option objects to preserve literal type inference.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 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 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.57%. Comparing base (573e8e7) to head (bc60cf4).
⚠️ Report is 13 commits behind head on chore/apis.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           chore/apis   #39779      +/-   ##
==============================================
+ Coverage       70.55%   70.57%   +0.01%     
==============================================
  Files            3256     3256              
  Lines          115791   115791              
  Branches        21083    21015      -68     
==============================================
+ Hits            81694    81715      +21     
+ Misses          32023    32011      -12     
+ Partials         2074     2065       -9     
Flag Coverage Δ
e2e 60.44% <ø> (+0.03%) ⬆️
e2e-api 49.06% <ø> (+0.96%) ⬆️
unit 71.07% <ø> (-0.04%) ⬇️

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 12 commits March 23, 2026 13:33
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…messages to OpenAPI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…umers

The declare module augmentation from ExtractRoutesFromAPI only works
within apps/meteor compilation. External packages like ddp-client need
the types to remain in rest-typings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion

The endpoint was missing a query validator, causing ExtractRoutesFromAPI
to extract undefined params. This broke consumers like useAppSlashCommands
that pass offset/count params.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sages

The migrated endpoints were using forbidden('error-not-allowed') as a
type workaround, but this changed the error response from 'unauthorized'
to 'error-not-allowed', breaking existing tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
API.v1.forbidden() without arguments returns 'unauthorized' for
backward compatibility. The test was expecting the old 'Not allowed'
message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ggazzo ggazzo marked this pull request as ready for review March 23, 2026 17:38
@ggazzo ggazzo requested review from a team as code owners March 23, 2026 17:38
@ggazzo ggazzo merged commit a7f20f0 into chore/apis Mar 23, 2026
43 of 44 checks passed
@ggazzo ggazzo deleted the chore/apis-2 branch March 23, 2026 17:39
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 7 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/im.ts">

<violation number="1" location="apps/meteor/app/api/server/v1/im.ts:313">
P2: `dm.setTopic` can return `topic: null` even though its response schema only permits string values.</violation>

<violation number="2" location="apps/meteor/app/api/server/v1/im.ts:752">
P3: `dm.create` and `im.create` now duplicate the same endpoint config and handler; extract one shared action/config to avoid divergence.</violation>
</file>

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

projection: fields,
});
return API.v1.success({
topic,
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

P2: dm.setTopic can return topic: null even though its response schema only permits string values.

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/im.ts, line 313:

<comment>`dm.setTopic` can return `topic: null` even though its response schema only permits string values.</comment>

<file context>
@@ -240,296 +219,597 @@ const dmCloseAction = <Path extends string>(_path: Path): TypedAction<typeof dmC
-				projection: fields,
-			});
+		return API.v1.success({
+			topic,
+		});
+	};
</file context>
Suggested change
topic,
topic: topic ?? '',
Fix with Cubic

.post('dm.close', dmCloseEndpointsProps, dmCloseAction('dm.close'))
.post('im.close', dmCloseEndpointsProps, dmCloseAction('im.close'))
.post(
'dm.create',
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

P3: dm.create and im.create now duplicate the same endpoint config and handler; extract one shared action/config to avoid divergence.

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/im.ts, line 752:

<comment>`dm.create` and `im.create` now duplicate the same endpoint config and handler; extract one shared action/config to avoid divergence.</comment>

<file context>
@@ -240,296 +219,597 @@ const dmCloseAction = <Path extends string>(_path: Path): TypedAction<typeof dmC
+	.post('dm.close', dmCloseEndpointsProps, dmCloseAction('dm.close'))
+	.post('im.close', dmCloseEndpointsProps, dmCloseAction('im.close'))
+	.post(
+		'dm.create',
+		{
+			authRequired: true,
</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