Skip to content

Allow relative private API host for wallet portfolio - #612

Merged
feruzm merged 1 commit into
developfrom
fm/investigate-missing-token-actions-on-wallet-page
Jan 11, 2026
Merged

Allow relative private API host for wallet portfolio#612
feruzm merged 1 commit into
developfrom
fm/investigate-missing-token-actions-on-wallet-page

Conversation

@feruzm

@feruzmferuzm commented Jan 11, 2026

Copy link
Copy Markdown
Member

Motivation

  • Wallet token actions on the Wallet page were not appearing on the main domain because the portfolio v2 query rejected an empty privateApiHost value used for relative API paths.
  • The app sets privateApiHost to an empty string on the main production domain to use relative endpoints, but the query treated that as missing and threw an error.
  • The goal is to allow empty string hosts so the Vision portfolio request can use relative URLs when running on ecency.com.

Description

  • Relaxed the host presence check in getVisionPortfolioQueryOptions by changing if (!CONFIG.privateApiHost) to an explicit undefined/null check.
  • This allows CONFIG.privateApiHost to be an empty string ('') so the endpoint can be built as a relative path (/wallet-api/portfolio-v2).
  • Updated file: packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts.

Testing

  • No automated tests were run for this change.
  • The change is a small guard modification and intended to allow the existing portfolio fetch logic to work with a relative privateApiHost.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Fixed validation logic for private API host configuration to properly distinguish between missing and explicitly empty values, improving reliability in edge case scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@feruzm
feruzm merged commit 9948516 into developJan 11, 2026
1 check was pending
@feruzm
feruzm deleted the fm/investigate-missing-token-actions-on-wallet-page branch January 11, 2026 23:03
@coderabbitai

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A validation check for CONFIG.privateApiHost is refined from truthiness evaluation to explicit undefined/null comparison, ensuring empty strings are properly handled within the error path.

Changes

Cohort / File(s)Summary
CONFIG validation refinement
packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts
Changed CONFIG.privateApiHost validation from truthiness check to explicit undefined/null comparison to correctly handle empty string edge cases

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • Fix wallet actions #611: Modifies the same file's VisionPortfolio parsing logic, presenting related structural changes within the query options module.

Poem

🐰 A whisker-thin fix with a hop and a bound,
Null checks now dance where truthiness drowned,
Empty strings caught in validation's embrace—
Config flows clean through this safer place! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Allow relative private API host for wallet portfolio' clearly describes the main change: enabling the use of relative API paths (empty string) for the private API host. It directly relates to the primary objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts (2)

217-221: LGTM! The relaxed check correctly enables relative API paths.

The change from a falsy check to an explicit undefined/null check appropriately allows empty-string hosts for relative endpoints while still guarding against truly missing configuration.

One optional consideration: whitespace-only strings (e.g., " ") would pass this check but produce malformed endpoints. You could leverage the existing normalizeString helper for consistency:

🔧 Optional: guard against whitespace-only strings
- if (CONFIG.privateApiHost === undefined || CONFIG.privateApiHost === null) {+ const host = typeof CONFIG.privateApiHost === "string" + ? CONFIG.privateApiHost.trim() + : CONFIG.privateApiHost;+ if (host === undefined || host === null) {

Then use host on line 223. This ensures whitespace-only values are treated as empty strings rather than producing paths like " /wallet-api/portfolio-v2".


223-223: Consider normalizing trailing slashes in the host.

If CONFIG.privateApiHost ever ends with a trailing slash (e.g., https://api.example.com/), the endpoint would become https://api.example.com//wallet-api/portfolio-v2 with a double slash. Most servers handle this gracefully, but for robustness:

🔧 Optional: strip trailing slash
- const endpoint = `${CONFIG.privateApiHost}/wallet-api/portfolio-v2`;+ const host = CONFIG.privateApiHost.replace(/\/+$/, "");+ const endpoint = `${host}/wallet-api/portfolio-v2`;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23ab03f and 478ba9d.

📒 Files selected for processing (1)
  • packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts

Sign up for freeto 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

@feruzm