Skip to content

Conversation

@FionnL
Copy link
Contributor

@FionnL FionnL commented Nov 28, 2025

Closes #ISSUE_NUMBER_GOES_HERE

Description

fix for pre release mobula-state v2 EA

Changes

  • Change getAssetId and getQuoteId to return undefined instead of throwing errors for unresolvable symbols
  • Update subscribeMessage builder to skip subscriptions that can't be resolved, logging a warning instead
  • Fix mock server in tests to handle undefined messages (when subscribeMessage returns undefined)
  • This prevents the EA from crashing when background cache warming encounters symbols not in includes.json
  • Other valid subscriptions will continue to work even if some symbols can't be resolved

Steps to Test

  1. Steps
  2. to
  3. test

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file.
  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • This is related to a maximum of one Jira story or GitHub issue.
  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

- Change getAssetId and getQuoteId to return undefined instead of throwing errors for unresolvable symbols
- Update subscribeMessage builder to skip subscriptions that can't be resolved, logging a warning instead
- Fix mock server in tests to handle undefined messages (when subscribeMessage returns undefined)
- This prevents the EA from crashing when background cache warming encounters symbols not in includes.json
- Other valid subscriptions will continue to work even if some symbols can't be resolved
@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: 6382f84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/mobula-state-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

// Check if we successfully resolved both IDs
if (assetId === undefined || quoteId === undefined) {
// Log warning but don't crash - this allows other subscriptions to continue
console.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logger instead

mockWsServer.on('connection', (socket) => {
socket.on('message', (message) => {
// Skip if message is undefined (happens when subscribeMessage returns undefined)
if (!message || message === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think !message is the same as message === 'undefined'

Copy link
Contributor

@mxiao-cll mxiao-cll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some tests

…equests

- Return undefined instead of throwing in getAssetId/getQuoteId for unresolvable symbols
- Skip subscriptions gracefully when symbols cannot be resolved
- Add requestTransforms to uppercase base/quote and resolve via includes.json
- Prevents background handler failures from breaking WebSocket connection
- Enables lowercase requests (btc/usd) to work seamlessly

This fixes the staging issue where external processes sending malformed/mixed-case
symbols (e.g. USDtb) caused the background subscription handler to throw errors,
preventing the WebSocket connection from being established and causing all
subsequent requests to fail with 504 timeouts.
Remove manual includes.json parsing in requestTransforms since the
framework already handles this automatically. Just uppercase the
parameters and let the framework apply includes.json transformations.

This removes 31 lines of redundant code.
- Use context.logger.warn instead of console.warn
- Simplify undefined check in fixtures.ts (!message vs !message || message === 'undefined')
@FionnL FionnL force-pushed the fix/mobula-graceful-unresolvable-symbols branch from 6831d2b to 2eb6146 Compare December 2, 2025 00:03
- BTC is not in includes.json as a base asset
- Changed lowercase test to use 'ezeth' which is in includes.json
- Changed recovery test to use 'RSETH' which is in includes.json
- Added RSETH mock data to fixtures
@FionnL FionnL force-pushed the fix/mobula-graceful-unresolvable-symbols branch from 06bb044 to 52bbd09 Compare December 2, 2025 01:30
@FionnL FionnL force-pushed the fix/mobula-graceful-unresolvable-symbols branch from c65de55 to 30349c0 Compare December 2, 2025 01:47
@FionnL FionnL requested a review from mxiao-cll December 2, 2025 02:35
transport: 'ws',
})
await testAdapter.waitForCache(8) // Wait for all primed pairs to be cached (7 new + 1 initial = 8 total, gho/usd doesn't create a new entry since it uppercases to GHO/USD)
}, 30000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should still work without the 30000

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.

3 participants