Skip to content

feat: Add response body or detail to errors#70

Open
DFEvans wants to merge 2 commits into
mainfrom
error_information
Open

feat: Add response body or detail to errors#70
DFEvans wants to merge 2 commits into
mainfrom
error_information

Conversation

@DFEvans
Copy link
Copy Markdown
Collaborator

@DFEvans DFEvans commented Mar 11, 2026

The error message shown for a ClientError or ServerError includes only the status code, excluding the usually verbose detail returned by the API.

Add the detail of a JSON response if it exists, or body of a string response, to the error message.

@DFEvans
Copy link
Copy Markdown
Collaborator Author

DFEvans commented Mar 11, 2026

Thoughts on tackling the test issues welcome - hit the same locally on main, and seems #69 is also seeing the same

@c-wygoda
Copy link
Copy Markdown
Contributor

fixed the catalog api builder issue. rebase and let's see some 🟢

The error message shown for a ClientError or ServerError includes
only the status code, excluding the usually verbose detail returned
by the API.

Add the detail of a JSON response if it exists, or body of a
string response, to the error message.
@DFEvans DFEvans force-pushed the error_information branch from 448a700 to b4ca48e Compare March 12, 2026 09:54
@DFEvans DFEvans marked this pull request as ready for review March 12, 2026 09:55
@DFEvans
Copy link
Copy Markdown
Collaborator Author

DFEvans commented Mar 12, 2026

TIL that ./scripts/test.sh doesn't run all of the tests...

@github-actions
Copy link
Copy Markdown
Contributor

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/satvu
   auth.py1203174%17–18, 66–74, 77–87, 90–100, 133, 137, 140–141, 228, 233–234
   sdk.py69199%59
   core.py93199%132
src/satvu/http
   urllib3_adapter.py1133866%10–11, 78–93, 100–101, 113–114, 125–126, 214–215, 250, 261–343
   requests_adapter.py842669%9–10, 74, 81–82, 94–95, 106–107, 186–187, 219, 230–290
   httpx_adapter.py822570%9–10, 73, 80–81, 95–96, 179–180, 222–292
   __init__.py31971%63–66, 71, 88–90, 93–95, 102
   stdlib_adapter.py1222976%75, 83–85, 101–104, 111–112, 125–126, 137–138, 244, 253, 289–355
   errors.py169696%157–158, 236–237, 441–442
src/satvu/services
   example_cache.py381268%58–59, 64–67, 70–75, 117–118
src/satvu/services/catalog
   api.py33112961%96, 102, 131, 137, 175, 207, 213, 251, 291, 320, 326, 356, 362, 436, 488–513, 554, 586–604, 672, 680, 733–758, 795, 825, 831, 899, 905, 958–983, 1020, 1050, 1056, 1125, 1133, 1186–1211, 1251, 1281, 1289, 1357, 1363, 1416–1441, 1478, 1508, 1514, 1567, 1573, 1615–1637, 1674, 1680, 1715–1734
   test_schemas.py25964%71591, 71623, 71651, 71656, 71669, 71674, 71679–71680, 71685
src/satvu/services/catalog/models
   acquisition_feature_collection_type.py5180%8
   acquisition_item_collection.py5180%8
   acquisition_item_type.py5180%8
   generic_item_type.py5180%8
   geo_json_geometry_collection_type.py5180%8
   geo_json_line_string_type.py5180%8
   geo_json_multi_line_string_type.py5180%8
   geo_json_multi_point_type.py5180%8
   geo_json_multi_polygon_type.py5180%8
   geo_json_point_type.py5180%8
   geo_json_polygon_type.py5180%8
   is_between_predicate_op.py5180%8
   is_in_list_predicate_op.py5180%8
   is_like_predicate_op.py5180%8
   is_null_predicate_op.py5180%8
   not_expression_op.py5180%8
   primary_feature_collection_type.py5180%8
   primary_item_collection.py5180%8
   primary_item_type.py5180%8
   surface_brightness_temperature_feature_collection_type.py5180%8
   surface_brightness_temperature_item_collection.py5180%8
   surface_brightness_temperature_item_type.py5180%8
   visual_feature_collection_type.py5180%8
   visual_item_collection.py5180%8
   visual_item_type.py5180%8
   and_or_expression_op.py6183%9
   binary_comparison_predicate_op.py10190%13
   arithmetic_expression_op.py11191%14
src/satvu/services/cos
   test_schemas.py25964%91875, 91907, 91935, 91940, 91953, 91958, 91963–91964, 91969
   api.py1523974%81, 120, 153, 184–196, 235, 264, 293–304, 355–356, 359–361, 472–473, 476–478, 584
src/satvu/services/cos/models
   method.py6183%9
   primary_format.py6183%9
   satvu_filter.py6183%9
   collection.py7186%10
src/satvu/services/id
   test_schemas.py25964%39258, 39290, 39318, 39323, 39336, 39341, 39346–39347, 39352
   api.py1442781%84, 112–129, 167, 202, 237, 277, 304, 312, 347, 382, 409, 417, 450, 483, 510, 516, 554
src/satvu/services/id/models
   notification_category.py5180%8
   reseller_webhook_event.py5180%8
   webhook_event.py5180%8
   reseller_notification_category.py6183%9
   topic.py6183%9
   webhook_failure_title.py7186%10
src/satvu/services/otm
   test_schemas.py25964%468433, 468465, 468493, 468498, 468511, 468516, 468521–468522, 468527
   api.py2285476%110, 141–153, 201, 232, 296, 325, 383–384, 387–389, 473, 511, 542–554, 585, 614, 644, 687, 726, 771, 795, 826, 855–866
src/satvu/services/otm/models
   sortable_field.py5180%8
   collection.py6183%9
   direction.py6183%9
   filter_.py6183%9
   full_well_capacitance.py6183%9
   primary_format.py6183%9
   readout_mode.py6183%9
   request_method.py6183%9
   collections.py7186%10
   day_night_mode.py7186%10
   feasibility_request_status.py9189%12
   order_status.py12192%15
src/satvu/services/policy
   test_schemas.py25964%2016, 2048, 2076, 2081, 2094, 2099, 2104–2105, 2110
   api.py30293%79, 117
src/satvu/services/reseller
   api.py1105154%72, 115, 143–160, 204, 233–250, 288, 317–334, 372, 401–418
   test_schemas.py25964%15622, 15654, 15682, 15687, 15700, 15705, 15710–15711, 15716
src/satvu/services/reseller/models
   request_method.py5180%8
   company_search_fields.py6183%9
   match_type.py6183%9
   kyc_status.py7186%10
   user_search_fields.py8188%11
   country_code.py239199%242
src/satvu/services/wallet
   test_schemas.py251060%658, 690, 695, 718, 723, 736, 741, 746–747, 752
   api.py27389%66, 94, 100
src/satvu/shared
   parsing.py40685%106, 131–136
TOTAL548760989% 

Tests Skipped Failures Errors Time
429 0 💤 0 ❌ 0 🔥 35.871s ⏱️

Comment thread scripts/bootstrap.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
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.

is there a reason to use bash? and if so, it must be called through /usr/bin/env as it's location can be different between OS, while /bin/sh is pretty much guaranteed to be there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

set -eo pipefail is a bash command - none of the scripts were valid sh scripts and crashed immediately for me.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(do Macs ship with a custom/aliased sh meaning it supports bash semantics? I was surprised this hadn't been noticed before)

Comment thread src/satvu/http/errors.py

def __init__(
self,
message: str,
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.

so no way to override anymore, even if we wanted, and changing the exception semantics as shown by massaging the tests into the new shape?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What use case do you have in mind for modifying the message?

The alternative I initially tried was managing the message setting each time the error is raised (well, created and put into an Err), but there's many places to do that across four different client implementations, which didn't seem right for a unified "report the error message as well as error code" change.

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.

2 participants