osparc-simcore icon indicating copy to clipboard operation
osparc-simcore copied to clipboard

🐛 Fixes unhandled `KeyError` when missing keys in exception's `msg_template`

Open pcrespov opened this issue 1 year ago • 2 comments

What do these changes do?

Addresses this error found in tip.science deploy

Unexpected KeyError: Oops! Something went wrong, 
but we've noted it down and we'll sort it out ASAP. 
Thanks for your patience! [OEC:139646582688800]

The api-server responds 500 to GET /v2/computations/ ... instead of 404 (in this case) due to an unhandled error

Details

  • 🧪 Reproduced logs in test_oec_139646582688800_missing_ctx_values_for_msg_template
    • The tests passes in HEAD master but tip.science is at v1.75.0
    • We believe this is caused because this fix https://github.com/ITISFoundation/osparc-simcore/pull/6064 was still not released there
  • 🎨 Overrides OsparcErrorMixin.__str__ to avoid raising KeyError when key is missing in template error messages. The message will include a default placeholder instead of raising and stopping execution

Related issue/s

  • Reported by @matusdrobuliak66 @Konohana0608 from tip.science (v1.75.0)

How to test

  • SEE services/api-server/tests/unit/test_services_directorv2.py reproduces log report

Dev-ops checklist

pcrespov avatar Aug 14 '24 12:08 pcrespov

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.0%. Comparing base (cafbf96) to head (70599d5). Report is 437 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6188      +/-   ##
=========================================
+ Coverage    84.5%   88.0%    +3.4%     
=========================================
  Files          10    1315    +1305     
  Lines         214   57071   +56857     
  Branches       25    1132    +1107     
=========================================
+ Hits          181   50261   +50080     
- Misses         23    6564    +6541     
- Partials       10     246     +236     
Flag Coverage Δ
integrationtests 64.8% <ø> (?)
unittests 85.8% <100.0%> (+1.3%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...odels-library/src/models_library/errors_classes.py 100.0% <100.0%> (ø)
...icelib/rabbitmq/rpc_interfaces/catalog/services.py 0.0% <ø> (ø)
...vice_api_server/exceptions/service_errors_utils.py 88.7% <100.0%> (ø)
...simcore_service_api_server/services/director_v2.py 80.2% <ø> (ø)

... and 1302 files with indirect coverage changes

codecov[bot] avatar Aug 14 '24 13:08 codecov[bot]