Gracefully handle a missing crypt key in the Query Tool connection endpoints#10065
Gracefully handle a missing crypt key in the Query Tool connection endpoints#10065dpage wants to merge 1 commit into
Conversation
…dpoints. After a backend/pod restart the in-memory crypt key is gone, so manager.connection() raises CryptKeyMissing. The new-connection endpoints (_check_server_connection_status and get_new_connection_*) swallowed it in a broad "except Exception", logged a full ERROR traceback, and returned a generic error the client cannot recognise. The standard recovery (a 503 CRYPTKEY_MISSING response that the client uses to transparently re-establish the key and retry) therefore never fired, leaving a spurious "Crypt key is missing" message in the Query Tool and noisy tracebacks in the log. Re-raise CryptKeyMissing (along with ConnectionLost / SSHTunnelConnectionLost) before the generic handler, matching the pattern already used by the query execution path, so these endpoints emit the standard CRYPTKEY_MISSING response and the client recovers gracefully. Closes pgadmin-org#10027
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR fixes Issue ChangesCryptKeyMissing Exception Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
After a backend/pod restart the in-memory crypt key is gone, so
manager.connection()raisesCryptKeyMissing. The Query Tool new-connectionendpoints (
_check_server_connection_statusand theget_new_connection_*handlers) swallowed it in a broad
except Exception, logged a full ERRORtraceback, and returned a generic error the client cannot recognise. The
standard recovery — a
503 CRYPTKEY_MISSINGresponse that the client uses totransparently re-establish the key and retry — therefore never fired, leaving
the spurious "Crypt key is missing" message in the Query Tool (and noisy
tracebacks in the log) reported in #10027.
This re-raises
CryptKeyMissing(along withConnectionLost/SSHTunnelConnectionLost) before the generic handler, matching the patternalready used by the query-execution path, so these endpoints emit the standard
CRYPTKEY_MISSINGresponse and the client recovers gracefully. No change tokey derivation or storage.
Test plan
503withCRYPTKEY_MISSINGwhen the crypt key is missing (previously aswallowed generic error), and that the normal path is unchanged
(
tools.sqleditor.tests.test_new_connection_dialog).pycodestyleclean.Closes #10027
Summary by CodeRabbit