Skip to content

fix(gateway): don't force-enable matrix-sdk via the metrics feature#1139

Open
resumeparseeval wants to merge 1 commit into
moltis-org:mainfrom
resumeparseeval:fix/metrics-no-force-enable-matrix
Open

fix(gateway): don't force-enable matrix-sdk via the metrics feature#1139
resumeparseeval wants to merge 1 commit into
moltis-org:mainfrom
resumeparseeval:fix/metrics-no-force-enable-matrix

Conversation

@resumeparseeval

Copy link
Copy Markdown

Summary

The gateway's metrics feature lists moltis-matrix/metrics without the weak ? qualifier, so enabling metrics force-enables the optional moltis-matrix dependency — pulling the entire matrix-sdk into the build even when the Matrix channel is otherwise disabled.

Every other optional channel in the same list already uses the weak form:

metrics = [
  "dep:moltis-metrics",
  "moltis-chat/metrics",
  "moltis-discord?/metrics",
  "moltis-matrix/metrics",     # <-- the lone non-weak ref
  "moltis-metrics/sqlite",
  "moltis-msteams?/metrics",
  "moltis-nostr?/metrics",
  "moltis-signal?/metrics",
]

moltis-matrix is the only inconsistency. The fix makes it weak (moltis-matrix?/metrics): metrics now enables matrix's metrics only when matrix is independently enabled, instead of dragging it into matrix-free builds.

Why this matters

A build that wants metrics but no Matrix (--no-default-features --features "...,metrics" without matrix) currently still compiles matrix-sdk. Besides the wasted build time, on the repo's pinned nightly matrix-sdk 0.16 currently fails to compile (error: queries overflow the depth limit), so this unnecessary edge makes otherwise-valid matrix-free builds fail. No effect on the default feature set, which enables matrix anyway.

Validation

Completed (via cargo tree)

  • cargo tree -p moltis-gateway --no-default-features --features metrics -i matrix-sdk"nothing to print" (was previously pulling matrix-sdk v0.16.0).
  • cargo tree -p moltis-gateway -i matrix-sdk (default features) → still resolves matrix-sdkno regression for default builds.
  • cargo metadata parses cleanly.

Remaining (CI / maintainer)

  • just release-preflight / full build matrix.

Manual QA

Build the gateway with metrics but without Matrix and confirm matrix-sdk is absent from the compile set:

cargo build -p moltis-gateway --no-default-features --features metrics

The `metrics` feature listed `moltis-matrix/metrics` (non-weak), which
turns on the optional `moltis-matrix` dependency — and so compiles the
whole `matrix-sdk` — whenever metrics are enabled, even for builds that
disable the Matrix channel. Every sibling channel in the same list already
uses the weak `dep?/feature` form (`moltis-discord?/metrics`,
`moltis-msteams?/metrics`, `moltis-nostr?/metrics`, `moltis-signal?/metrics`);
matrix is the lone inconsistency.

Make it weak too: `moltis-matrix?/metrics`. The `metrics` feature now only
enables matrix's own metrics when matrix is independently enabled, instead
of dragging matrix into otherwise matrix-free builds.

Verified with cargo tree:
- `--no-default-features --features metrics` no longer pulls matrix-sdk.
- the default feature set still includes matrix-sdk (no behavior change).
@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the gateway metrics feature wiring.

  • Matrix metrics now use weak optional-dependency forwarding.
  • Metrics-only builds no longer activate the Matrix dependency.
  • Default builds still enable Matrix metrics when Matrix is enabled.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • When Matrix is enabled, the weak feature reference still enables Matrix metrics.
  • When Matrix is disabled, skipping Matrix metrics matches the missing Matrix dependency.

Important Files Changed

Filename Overview
crates/gateway/Cargo.toml Changes the Matrix metrics feature reference to match the weak forwarding pattern used by the other optional channel crates.

Reviews (1): Last reviewed commit: "fix(gateway): don't force-enable matrix-..." | Re-trigger Greptile

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