Skip to content

Missing null check for token metadata in spot portfolio #24

Description

@MayurK-cmd

When displaying a wallet's portfolio, the command fetches token metadata from the Datapi client. If any mint's metadata is not found (e.g., API failure, new token not indexed), the code silently skips that token via continue, masking the API issue. This can lead to incomplete or misleading portfolio displays without user awareness.

Expected behavior:

  • Log a warning when token metadata is missing
  • Still display the token with available information (mint address, on-chain balance)
  • Or throw a clear error if critical metadata is unavailable

Current behavior:

  • Silently skips tokens with missing metadata
  • User has no indication that their portfolio is incomplete

Location: src/commands/SpotCommand.ts:401-404

Suggested fix:
for (const [mint, ata] of ataByMint) {
if (mint === Asset.SOL.id) {
continue;
}
const info = tokenMap.get(mint);
if (!info) {
console.warn(
Warning: Could not fetch metadata for token ${mint}. Skipping.
);
continue;
}
// ... rest of logic
}

Type: Bug - Error Handling

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions