Skip to content

fix(leads): replace string Convex mutation names with typed api.* handles#3292

Open
octo-patch wants to merge 1 commit into
koala73:mainfrom
octo-patch:fix/issue-3253-typed-convex-handles
Open

fix(leads): replace string Convex mutation names with typed api.* handles#3292
octo-patch wants to merge 1 commit into
koala73:mainfrom
octo-patch:fix/issue-3253-typed-convex-handles

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

Fixes #3253

Problem

Three files called Convex mutations/queries using string-based names cast as any:

  • server/worldmonitor/leads/v1/submit-contact.ts: 'contactMessages:submit' as any
  • server/worldmonitor/leads/v1/register-interest.ts: 'registerInterest:register' as any
  • api/user-prefs.ts: 'userPreferences:getPreferences' as any and 'userPreferences:setPreferences' as any

String-based mutation names bypass TypeScript type checking and break silently when mutations are renamed.

Solution

Import the generated api object from convex/_generated/api and replace each string name with its typed api.* handle:

  • 'contactMessages:submit' as anyapi.contactMessages.submit
  • 'registerInterest:register' as anyapi.registerInterest.register
  • 'userPreferences:getPreferences' as anyapi.userPreferences.getPreferences
  • 'userPreferences:setPreferences' as anyapi.userPreferences.setPreferences

Also removes the // eslint-disable-next-line @typescript-eslint/no-explicit-any comments in user-prefs.ts that were suppressing the linter warnings.

Testing

  • All four Convex function names verified to exist in their respective modules (convex/contactMessages.ts, convex/registerInterest.ts, convex/userPreferences.ts)
  • Generated convex/_generated/api.js exports api = anyApi which correctly resolves typed handles at runtime
  • No behavioral change — typed handles produce identical wire calls as string names

…dles

Replaces 'contactMessages:submit' as any, 'registerInterest:register' as any,
and 'userPreferences:*' as any with typed api.* function references from
convex/_generated/api. This gives compile-time verification that the mutation
exists with the expected arg shape and prevents silent breakage on rename.

Fixes koala73#3253
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

Someone is attempting to deploy a commit to the World Monitor Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the trust:suspicious Brin: contributor trust score suspicious label Apr 22, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

Replaces string-literal Convex mutation/query names (cast as any) with typed api.* handles imported from convex/_generated/api across three files. The change is a pure type-safety upgrade — anyApi at runtime resolves identically to the previous string references, so there is no behavioral difference.

Confidence Score: 5/5

Safe to merge — purely mechanical type-safety improvement with no runtime behavior change.

All four typed handles are confirmed present in convex/_generated/api.d.ts. The runtime implementation (api = anyApi) is equivalent to the previous string-based approach. No P0/P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
api/user-prefs.ts Replaces 'userPreferences:getPreferences' as any and 'userPreferences:setPreferences' as any with api.userPreferences.getPreferences / api.userPreferences.setPreferences; removes two @typescript-eslint/no-explicit-any disable comments. Both functions exist in convex/_generated/api.d.ts.
server/worldmonitor/leads/v1/register-interest.ts Adds import { api } from '../../../../convex/_generated/api' and replaces 'registerInterest:register' as any with api.registerInterest.register. Module exists in the generated API declaration.
server/worldmonitor/leads/v1/submit-contact.ts Adds import { api } from '../../../../convex/_generated/api' and replaces 'contactMessages:submit' as any with api.contactMessages.submit. Module exists in the generated API declaration.

Sequence Diagram

sequenceDiagram
    participant C as Client
    participant H as Edge Handler
    participant CV as ConvexHttpClient
    participant DB as Convex DB

    C->>H: HTTP Request (GET/POST)
    H->>H: Auth & validate
    H->>CV: client.query/mutation(api.*.*, args)
    Note over H,CV: Previously: 'moduleName:fn' as any
    Note over H,CV: Now: typed api.* handle (same wire call)
    CV->>DB: Convex RPC
    DB-->>CV: Result
    CV-->>H: Typed response
    H-->>C: JSON Response
Loading

Reviews (1): Last reviewed commit: "fix(leads): replace string Convex mutati..." | Re-trigger Greptile

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

Labels

trust:suspicious Brin: contributor trust score suspicious

Projects

None yet

Development

Successfully merging this pull request may close these issues.

leads: replace 'as any' on Convex mutation names with typed api.* handles

1 participant