Skip to content

chore: allow parameterless internalError calls#40756

Open
nazabucciarelli wants to merge 4 commits into
developfrom
chore/fix-internal-error-response
Open

chore: allow parameterless internalError calls#40756
nazabucciarelli wants to merge 4 commits into
developfrom
chore/fix-internal-error-response

Conversation

@nazabucciarelli
Copy link
Copy Markdown
Contributor

@nazabucciarelli nazabucciarelli commented Jun 1, 2026

Proposed changes (including videos or screenshots)

Fixes a TypeScript compilation error (Type 'unknown' is not assignable to type 'InternalErrorResponse') that occurs when calling API.v1.internalError() without arguments in endpoints strictly typed with AJV schemas.
There were two underlying typing issues preventing parameterless calls to internalError from passing strict AJV schema validations:

  1. Missing Overload: When internalError() was called without arguments, TypeScript inferred the generic T as unknown.
  2. Incorrect Type Extraction: In definition.ts, ErrorStatusCodes (500) was using InferResult<TResponse[500]> instead of InferNon200Result. This caused the framework to expect the entire response object ({ success: false, error: string }) as the generic type instead of just extracting the error payload type, unlike how 401, 403, and 404 errors are handled.

Issue(s)

CORE-2277 Fix TypeScript compilation error on parameterless API.v1.internalError() calls

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor
    • Improved internal error-handling type inference to make server-side error responses more precise and consistent.

Note: These are internal infrastructure improvements with no user-visible changes.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Jun 1, 2026

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

  • This PR is missing the 'stat: QA assured' label

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 Jun 1, 2026

⚠️ No Changeset found

Latest commit: fd53c16

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 Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 11ae60f2-9a45-479c-8023-52841b529e69

📥 Commits

Reviewing files that changed from the base of the PR and between 997790f and fd53c16.

📒 Files selected for processing (1)
  • apps/meteor/app/api/server/definition.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/app/api/server/definition.ts
📜 Recent 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). (5)
  • GitHub Check: ⚙️ Variables Setup
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check

Walkthrough

The PR refines TypeScript typings for internal error handling: internalError is split into explicit overloads (no-arg and generic-arg), and InternalError response typing now uses InferNon200Result<TResponse[K]> to derive the body.error shape per error status code.

Changes

Internal Error Type Refinements

Layer / File(s) Summary
Error method overloads and response type inference
apps/meteor/app/api/server/ApiClass.ts, apps/meteor/app/api/server/definition.ts
internalError now has two overloads: internalError(): InternalError<never> and internalError<T>(msg: T): InternalError<T>. The InternalError response mapping for ErrorStatusCodes now derives body.error using InferNon200Result<TResponse[K]> (status-specific non-200 shape) instead of the previous inference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding TypeScript support for parameterless internalError() calls, which is the primary fix addressed in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2277: Request failed with status code 401

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.

@nazabucciarelli nazabucciarelli changed the title chore: enhance internal error response chore: allow parameterless internalError calls Jun 1, 2026
@nazabucciarelli nazabucciarelli added this to the 8.6.0 milestone Jun 1, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.72%. Comparing base (0ef1002) to head (fd53c16).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40756      +/-   ##
===========================================
- Coverage    69.76%   69.72%   -0.04%     
===========================================
  Files         3327     3327              
  Lines       123134   123134              
  Branches     21987    21933      -54     
===========================================
- Hits         85904    85858      -46     
- Misses       33869    33915      +46     
  Partials      3361     3361              
Flag Coverage Δ
e2e 59.39% <ø> (+0.07%) ⬆️
e2e-api 46.07% <ø> (-0.93%) ⬇️
unit 70.42% <ø> (-0.07%) ⬇️

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.

@nazabucciarelli nazabucciarelli marked this pull request as ready for review June 1, 2026 21:26
@nazabucciarelli nazabucciarelli requested a review from a team as a code owner June 1, 2026 21:26
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/app/api/server/definition.ts`:
- Line 365: The error branch is incorrectly inferring all non-200 error payloads
from TResponse[500]; update the InternalError generic to use the current status
key so the payload type is TResponse[K] instead of TResponse[500]. Locate the
occurrence of InternalError<InferNon200Result<TResponse[500]>, K> (in the
response/error type construction) and change it to
InternalError<InferNon200Result<TResponse[K]>, K> so each error status (e.g.,
501/502) infers its own payload via TResponse[K].
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08561b3e-9bd0-4ea6-bef3-54ce1e38f9dc

📥 Commits

Reviewing files that changed from the base of the PR and between 0ef1002 and 997790f.

📒 Files selected for processing (2)
  • apps/meteor/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/definition.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). (6)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 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/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/definition.ts
🧠 Learnings (3)
📚 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/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/definition.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/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/definition.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/api/server/ApiClass.ts
  • apps/meteor/app/api/server/definition.ts
🔇 Additional comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)

349-361: LGTM!

Comment thread apps/meteor/app/api/server/definition.ts Outdated
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.

No issues found across 2 files

Re-trigger cubic

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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