fix(errors): parse structured server errors carrying a legacy C-layer banner - #3408
Open
PProfizi wants to merge 4 commits into
Open
fix(errors): parse structured server errors carrying a legacy C-layer banner#3408PProfizi wants to merge 4 commits into
PProfizi wants to merge 4 commits into
Conversation
…r banner
The CAPI raise path prefixes the structured JSON error with a legacy C-layer
banner ("a '...' error occurred: {...}"), which defeated the
_parse_structured_error startswith("{") check and caused the raw JSON to be
printed. Strip the banner before parsing so these errors render as a readable
root-cause message plus the operator-chain note.
PProfizi
commented
Aug 25, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3408 +/- ##
===========================================
+ Coverage 44.70% 82.75% +38.05%
===========================================
Files 95 95
Lines 11791 11791
===========================================
+ Hits 5271 9758 +4487
+ Misses 6520 2033 -4487 |
Server startup failures surface the structured error as raw JSON prefixed with a "DPF Error:" banner and are raised as a plain RuntimeError, bypassing DPFServerException. Add a reusable format_dpf_error() helper (banner-aware, tolerant of the payload appearing on one line of multi-line stderr) and use it when raising the startup RuntimeError so the root-cause message and operator chain are shown instead of the raw dictionary.
ansys-akarcher
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the handling and formatting of DPF server error messages, especially those containing structured error payloads with legacy banners. The changes improve error readability for both users and developers by standardizing error output and ensuring that structured errors are properly parsed and displayed.
Error handling improvements:
format_dpf_errorfunction insrc/ansys/dpf/gate/errors.pyto extract and render human-readable messages from possibly structured DPF error strings, including those prefixed with legacy banners.read_stdoutinsrc/ansys/dpf/core/server_types.pyto useformat_dpf_errorwhen raising runtime errors, ensuring consistent error formatting.Structured error parsing enhancements:
_parse_structured_errorinsrc/ansys/dpf/gate/errors.pyto recognize and strip legacy error banners before parsing JSON, allowing for better detection of structured errors._LEGACY_BANNERto identify and remove legacy error prefixes [1] [2].Testing and validation:
tests/test_server_errors.pyto verify handling of structured errors with legacy banners, multi-line errors, and plain messages, ensuring the new formatting logic works as intended.Imports and code organization:
format_dpf_errorto the public API ofsrc/ansys/dpf/core/errors.py.