Skip to content

fix(cyphergoat): do not lose swaps to response parsing; redact logged uris - #1497

Closed
sneurlax wants to merge 1 commit into
stagingfrom
fix/cyphergoat-response-parsing-and-secrets
Closed

sneurlax wants to merge 1 commit into
stagingfrom
fix/cyphergoat-response-parsing-and-secrets

Conversation

@sneurlax

@sneurlax sneurlax commented Nov 1, 2026

Copy link
Copy Markdown
Member

CgTransaction hard required Provider, Done, Payment and EstimateId, and CgEstimatesResponse hard required TradeValue_fiat, TradeValue_btc and EstimateId. Nothing in lib/ reads them, but a missing one throws out of fromMap after the server has already created the swap, so the deposit address is dropped and the user gets a parse error with no way to track the trade. The same throw in getTransaction breaks status updates for a live trade, and on /estimate it takes out the whole quote list.

Drop the unused fields. EstimateId on the estimate response is sent back as estimateid on /swap, so it becomes int? and createSwap's existing null guard skips it rather than sending 0. requireCgDecimal now throws CgResponseFormatException on empty or unparsable strings instead of dying in Decimal.parse.

In _makeGetRequest, json["error"].toString() returned "null" when there was no error key, so a 400 reached the user as "Exception: null". Check the status before decoding, extract the error properly, and fall back to the status code plus the first 200 characters of the body, so an html 502 page reports 502 without filling the dialog.

CypherGoat and Trocador logged full request uris at error level, which go into latest.txt and the log export users attach to support threads. Add Uri.redacted, which strips key and address query parameters, and use it at those log sites.

… uris

CgTransaction hard required Provider, Done, Payment and EstimateId, and
CgEstimatesResponse hard required TradeValue_fiat, TradeValue_btc and
EstimateId. Nothing in lib/ reads them, but a missing one throws out of
fromMap after the server has already created the swap, so the deposit
address is dropped and the user gets a parse error with no way to track
the trade. The same throw in getTransaction breaks status updates for a
live trade, and on /estimate it takes out the whole quote list.

Drop the unused fields. EstimateId on the estimate response is sent back
as estimateid on /swap, so it becomes int? and createSwap's existing null
guard skips it rather than sending 0. requireCgDecimal now throws
CgResponseFormatException on empty or unparsable strings instead of
dying in Decimal.parse.

In _makeGetRequest, json["error"].toString() returned "null" when there
was no error key, so a 400 reached the user as "Exception: null". Check
the status before decoding, extract the error properly, and fall back to
the status code plus the first 200 characters of the body, so an html
502 page reports 502 without filling the dialog.

CypherGoat and Trocador logged full request uris at error level, which
go into latest.txt and the log export users attach to support threads.
Add Uri.redacted, which strips key and address query parameters, and use
it at those log sites.

Closes F13, F25, F26, F27, F30, F59.
@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.38462% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.81%. Comparing base (ad1efd5) to head (bdee51e).
⚠️ Report is 1 commits behind head on staging.

Files with missing lines Patch % Lines
...b/services/exchange/cyphergoat/cyphergoat_api.dart 0.00% 6 Missing ⚠️
lib/services/exchange/trocador/trocador_api.dart 0.00% 2 Missing ⚠️
...vices/exchange/cyphergoat/cyphergoat_exchange.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1497      +/-   ##
===========================================
+ Coverage    10.74%   10.81%   +0.06%     
===========================================
  Files         1132     1133       +1     
  Lines       113993   113999       +6     
===========================================
+ Hits         12254    12328      +74     
+ Misses      101739   101671      -68     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sneurlax

sneurlax commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Should be redone, I rebased it yesterday but on a closer look this is just ... messy

@sneurlax sneurlax closed this Nov 2, 2026
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