Skip to content

Fix Sales opportunity 502s by initializing the M2M client - #66

Merged
jmgasper merged 1 commit into
masterfrom
fix/projects-m2m-client-master
Nov 5, 2026
Merged

jmgasper merged 1 commit into
masterfrom
fix/projects-m2m-client-master

Conversation

@jmgasper

@jmgasper jmgasper commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Opening an opportunity in Sales returns 502: Unable to load opportunity billing accounts because Projects API never initializes its outbound M2M client. The released tc-core-library-js v4 exposes createM2MClient at the top level, but the constructor still checks the removed auth.m2m export and skips initialization.

Initialize the client directly through the typed factory so billing-account lookups can obtain a machine token. Existing Auth0 endpoint, proxy, audience, credential lookup, and token-error behavior are preserved. Invalid endpoint configuration now fails during service construction instead of leaving a silently uninitialized client.

Validation:

  • Added tests using the installed tc-core library and a local token endpoint for token acquisition/caching, missing credentials, and upstream rejection. All three reproduced the old initialization failure before the fix and pass afterward.
  • Full Jest suite on Node 26: 532 passed, 3 skipped (66 passing suites).
  • Nest production build, ESLint on changed files, and git diff --check passed.
  • No production credentials or external token endpoints were used in tests.

Deployment: deploy Projects API after merging, then verify that opening a Sales opportunity loads its details and billing context. No configuration or database migration is required. Live recovery remains to be verified after deployment.

@jmgasper
jmgasper merged commit 87dc6a9 into master Nov 5, 2026
3 checks passed
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