Skip to content

fix(config): trim surrounding whitespace from a config value, and from a saved nodeURL - #705

Open
ipezygj wants to merge 3 commits into
hummingbot:developmentfrom
ipezygj:fix/trim-config-strings
Open

ipezygj wants to merge 3 commits into
hummingbot:developmentfrom
ipezygj:fix/trim-config-strings

Conversation

@ipezygj

@ipezygj ipezygj commented Sep 21, 2026 •

Copy link
Copy Markdown

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:

Addresses hummingbot/hummingbot-api#233 on the Gateway side.

A nodeURL saved as ' https://...' passes the JSON schema, which only asks for a string, and is written to the YAML as-is. It then fails inside the RPC client, not at save time: Solana's Connection rejects it with Endpoint URL must start with http: or https: on the first /wallet/add or balance call, which is where the report saw it. The fix in that thread was on the Condor side; a write through the Gateway API or Swagger, or a hand edit of the YAML, still stored the space, and a config that already had one stayed broken until re-saved.

Two small changes:

  • POST /config/update trims a string value whose field name ends in URL before the type conversion and the write, so what reaches the YAML is the URL the user meant. Other strings are stored as sent: an exchange credential such as the OKX passphrase goes out verbatim, so its whitespace, if any, is part of the value. The number and boolean conversions read the trimmed text, so ' true ' for a boolean setting is true (it was compared unequal to 'true' and stored as false).
  • getSolanaNetworkConfig and getEthereumNetworkConfig trim nodeURL when they read it. Every consumer of the URL goes through these, so a value already on disk with a space works without being re-saved.

Nothing changes for a value that has no surrounding whitespace.

Tests performed by the developer:

  • New test/config/node-url-whitespace.test.ts: a nodeURL stored with a leading space (Solana) and a trailing newline (Ethereum) is read back clean. Both fail on development without the change.
  • New cases in test/config/config-routes-v2.test.ts: /config/update with ' https://... ' on nodeURL calls updateConfig with the trimmed URL (fails on development without the change); ' pass phrase ' on okx.passphrase is passed through unchanged; ' true ' on server.logColors is stored as true (fails on development without the change).
  • test/config/ and test/rpc/rpc-provider-simple.test.ts pass; pnpm typecheck and eslint/prettier are clean on the changed files.

Tips for QA testing:

  1. POST /config/update with {"namespace": "solana-mainnet-beta", "path": "nodeURL", "value": " https://api.mainnet-beta.solana.com"}; conf/chains/solana/mainnet-beta.yml should hold the URL without the space.
  2. Stop Gateway, put a leading space in front of nodeURL in that YAML by hand, start Gateway, then POST /wallet/add for a Solana wallet. Before this change: Endpoint URL must start with http: or https:. After: the wallet is added.

…m a saved nodeURL

A nodeURL saved as ' https://...' passes the JSON schema, which only asks
for a string, and fails later inside the RPC client: Solana's Connection
rejects it with "Endpoint URL must start with `http:` or `https:`" on the
first wallet or balance call, far from where the value was entered.

/config/update now trims a string value before the type conversion and the
write. The two chain config loaders trim nodeURL when they read it, so a
value already on disk with a space - pasted into the YAML, or written
before this change - keeps working without being re-saved.

Reported in hummingbot/hummingbot-api#233; Condor trims on its side, the
direct API and the YAML did not.
@greptile-apps

greptile-apps Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; both previous configuration-conversion defects are resolved and no new actionable issue was identified.

Summary

This PR normalizes surrounding whitespace in Ethereum and Solana node URLs while preserving exact non-URL string values.

  • Trims URL fields before configuration persistence.
  • Uses trimmed text when converting numeric and Boolean string inputs.
  • Trims existing nodeURL values when chain network configuration is loaded.
  • Adds regression coverage for URL normalization, credential preservation, and padded Boolean conversion.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Input[Configuration input] --> Kind{Value kind}
    Kind -->|URL field| TrimSave[Trim and persist]
    Kind -->|Number or Boolean| TrimConvert[Trim temporary text and convert]
    Kind -->|Other string| Preserve[Persist exactly as supplied]
    TrimSave --> Config[Validated configuration]
    TrimConvert --> Config
    Preserve --> Config
    Config --> Loader[Chain network loader]
    Loader --> TrimRead[Trim nodeURL on read]
    TrimRead --> RPC[RPC client]
Loading

Reviews (3) · Last reviewed commit: "fix(config): convert a padded string num..."

Comment thread src/config/routes/updateConfig.ts Resolved
…hitespace

An exchange credential such as the OKX passphrase is sent verbatim, so
trimming every string through /config/update could alter it. The trim is
now limited to fields whose name ends in URL, which is where the failure
was.
Comment thread src/config/routes/updateConfig.ts Resolved
… text

' true ' for a boolean setting compared unequal to 'true' and was stored as
false. The conversions now read the trimmed text; a non-URL string is
still stored as sent.
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