Skip to content

chore: log deprecation for unused DDP methods without a REST replacement#40657

Draft
ggazzo wants to merge 9 commits into
developfrom
chore/ddp-deprecation-no-replacement
Draft

chore: log deprecation for unused DDP methods without a REST replacement#40657
ggazzo wants to merge 9 commits into
developfrom
chore/ddp-deprecation-no-replacement

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented May 22, 2026

Summary

Adds methodDeprecationLogger.method(name, '9.0.0', []) to every orphan Meteor (DDP) method that does not have a REST endpoint to migrate callers to. The log line warns external clients that the method will be removed in 9.0.0 without pointing at a substitute.

Companion PR layout:

Used methods without a REST replacement are not in this PR. The deprecation logger throws under TEST_MODE, so deprecating a live method breaks the test suite. Those methods either need a new REST endpoint first or stay registered until 9.0.0 cleanup.

Scope

71 deprecation calls across 62 files. Each call sits above a // @deprecated JSDoc on the implementation so editors strike through the method name. Files already had their imports pruned and were not deleted (the implementations still ship — only the log line is new).

Caveats

Test plan

  • CI test suites stay green (no live methods deprecated).
  • Spot-check the listed methods against external SDK usage to make sure the no-replacement message is accurate.

ggazzo added 4 commits May 22, 2026 13:22
scripts/audit-ddp-methods.mjs walks the monorepo to enumerate every
Meteor.methods registration, find their callers across server/client/
ee, and cross-reference against REST endpoints registered in
apps/meteor/app/api/server. Produces docs/ddp-audit.{json,md} with
three buckets: used methods, orphans (no caller), and used methods
without a REST replacement.

scripts/add-ddp-deprecation.mjs consumes that audit and inserts
methodDeprecationLogger.method(name, '9.0.0', replacement) into the
body of every orphan and every used-method-with-REST-replacement,
adding the import in the relative-imports group. Skips methods that
already log a deprecation. Supports shorthand, colon-function, arrow,
and twoFactorRequired-wrapped registration shapes.
Adds methodDeprecationLogger.method() calls to 148 Meteor methods that
are either orphan (no caller found in the repo) or already have a REST
endpoint replacement. Methods with the call now warn that they will be
removed in 9.0.0, and when applicable point to the replacement endpoint.

Methods still in use without a REST equivalent are intentionally left
untouched until a replacement endpoint exists. Already-deprecated
methods (sendFileMessage, starMessage, insertOrUpdateSound,
uploadCustomSound) are kept as-is.

Generated by scripts/add-ddp-deprecation.mjs from docs/ddp-audit.json.
The audit script picked up 'settings' and 'context' as method names from
inside an object-literal return value and a JSDoc `@param` block. Those
two methodDeprecationLogger calls were injected into the bodies of
rocketchatSearch.getProvider and rocketchatSearch.search by mistake.
Neither method is a deprecation target.
Initial pass shipped 18 deprecation-message replacements that pointed
developers at REST endpoints with materially different semantics or at
paths that did not exist. Independent review classified them as WRONG,
MISSING, or PARTIAL with silent-break risk:

  WRONG  (drop replacement, keep deprecation)
    - 2fa:enable        (TOTP enable vs email-2fa enable)
    - 2fa:disable       (TOTP disable vs send email code)
    - deleteFileMessage (single-msg vs rooms.cleanHistory range purge)
    - getMessages       (batched IDs vs single chat.getMessage)
    - loadNextMessages, loadSurroundingMessages
                        (forward/window fetch vs chat.syncMessages delta)
    - readThreads       (one thread vs whole-room read)
    - getSetupWizardParameters (wizard subset vs settings.public)
    - banner/dismiss    (per-user set vs Banner.dismiss broadcast)

  MISSING
    - saveSettings      (/v1/settings does not exist; only /v1/settings/:_id)

  PARTIAL (room-type or shape mismatch — silent break for callers)
    - loadHistory, joinRoom, leaveRoom, addUsersToRoom,
      getRoomByTypeAndName (channels.* fails on p/d/l rooms)
    - loadMissedMessages (chat.syncMessages has incompatible response)
    - spotlight, slashCommand (REST drops required params)

For all 18, the replacement argument is now an empty array so the
deprecation logger still reports the removal version without pointing
to a wrong endpoint.

Also fills four mappings that the previous heuristic missed because of
case/separator differences or an unscanned EE api directory:

    - autoTranslate.getSupportedLanguages
        -> /v1/autotranslate.getSupportedLanguages
    - autoTranslate.translateMessage
        -> /v1/autotranslate.translateMessage
    - subscriptions/get
        -> /v1/subscriptions.get
    - getReadReceipts (EE)
        -> /v1/chat.getMessageReadReceipts

scripts/audit-ddp-methods.mjs gains:
  - REST_DENYLIST that hard-blocks the 18 misleading mappings from being
    re-derived if the heuristic runs again,
  - lower-case and `/`-vs-`.` separator candidate paths so similarly
    misspelled mappings get matched,
  - apps/meteor/ee/server/api/ added to REST_DIRS so EE endpoints are
    visible to the audit.

docs/ddp-replacement-review.md captures the per-method review notes.
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 22, 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 May 22, 2026

⚠️ No Changeset found

Latest commit: de3a4a2

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 May 22, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 79e0c1d9-1548-4193-87f6-fa00e0b11508

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 May 22, 2026

Codecov Report

❌ Patch coverage is 10.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.63%. Comparing base (f7d47dd) to head (de3a4a2).
⚠️ Report is 8 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40657      +/-   ##
===========================================
- Coverage    69.64%   69.63%   -0.01%     
===========================================
  Files         3338     3338              
  Lines       123232   123237       +5     
  Branches     21989    21974      -15     
===========================================
- Hits         85830    85822       -8     
- Misses       34049    34057       +8     
- Partials      3353     3358       +5     
Flag Coverage Δ
unit 70.45% <10.00%> (-0.02%) ⬇️

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 added 2 commits May 22, 2026 14:42
Adds a JSDoc `@deprecated` block above every Meteor.methods({...})
entry that the audit flagged as an orphan (no caller found in the
repository). The message also explains the rationale — these methods
remain registered for external DDP consumers (mobile SDK, custom
integrations) but should not be picked up as new dependencies inside
the monorepo.

110 entries annotated across 101 files. 2 entries already had a
`@deprecated` block from earlier and were left untouched.

scripts/add-orphan-jsdoc.mjs reads docs/ddp-audit.json and walks every
`Meteor.methods({...})` body (skipping the `declare module
'@rocket.chat/ddp-client'` interface blocks above) so the comment
lands on the implementation, not the type augmentation.
The deprecation logger throws in TEST_MODE
(apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts:118), so a
deprecation log on a method that's still invoked by integration or
unit tests turns those tests into failures with messages like:

    Error: The method "addUsersToRoom" is deprecated and will be
    removed on version 9.0.0

That's the intended dev-loop guard rail, but it means this PR can
only carry deprecation calls on methods with **no callers**.

Removes the 83 logger calls (and their now-unused imports) that
targeted methods listed in audit.used. They will be revisited as part
of the caller-migration PR #40659 — once each callsite moves to the
matching REST endpoint, the DDP method can either get a deprecation
log here or be removed outright in #40656.

What remains in this PR: 71 deprecation calls, all on orphan methods
without a REST replacement.
@ggazzo ggazzo changed the title chore: log deprecation for DDP methods without a REST replacement chore: log deprecation for unused DDP methods without a REST replacement May 22, 2026
ggazzo added 3 commits May 22, 2026 18:22
The deprecation logger throws under TEST_MODE so accidental usage of a
deprecated method or endpoint surfaces immediately. That guard rail is
correct for unit tests, but the API end-to-end suite intentionally
exercises DDP methods through the `/v1/method.call/:method` proxy and
through streamer paths to keep coverage on those code paths until the
methods are actually removed.

Introduces a second env var, `TEST_MODE_API`, that suppresses the throw
while keeping the warn log:

  - apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts: a
    `shouldThrowOnDeprecation()` helper replaces the seven inline
    `if (process.env.TEST_MODE === 'true') throw` blocks, gated on
    both TEST_MODE being true and TEST_MODE_API NOT being true.

  - docker-compose-ci.yml: the rocketchat and omnichannel-transcript
    services now pass `TEST_MODE_API` through to the container so the
    Node process sees it.

  - .github/workflows/ci-test-e2e.yml: the `E2E Test API` and
    `E2E Test API (Livechat)` jobs set `TEST_MODE_API: 'true'` so
    the suppression only kicks in for those runs.

UI and Unit test runs still throw on accidental deprecated usage.
The previous patch set TEST_MODE_API on the `E2E Test API` step,
which runs *after* docker compose has already started the rocketchat
container — so the env var never reached the Node process.

Move the export to the `Start containers` steps (CE + EE) gated on
`inputs.type == 'api' || inputs.type == 'api-livechat'` so the var
exists in the shell when docker compose substitutes it into the
container's environment from `docker-compose-ci.yml`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant