feat: Enhance placeholder resolution and error handling
Deploy Development / deploy (push) Successful in 55s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Updated `extract_value_raw` to improve JSON parsing and handle unavailable data more effectively.
- Introduced new functions in `placeholder_resolver.py` for standardized responses when data is unavailable, enhancing clarity for users and AI.
- Modified various data retrieval functions to utilize the new response format, providing detailed reasons for unavailability.
- Improved availability checks in `export_placeholder_values_extended` to account for new response formats.

These changes enhance the robustness of the placeholder system and improve user experience by providing clearer error messages and data handling.
This commit is contained in:
Lars committed 2026-04-11 21:22:27 +02:00
1 parent 052ba195cc
commit 04e23d8115
4 files changed
+320 -34

No files matched your search

+10 -2
View File
@@ -29,14 +29,22 @@ def extract_value_raw(value_display: str, output_type: OutputType, placeholder_t
Returns: (raw_value, success)
"""
if not value_display or value_display in ['nicht verfügbar', 'nicht genug Daten']:
s = (value_display or "").strip()
if (
not s
or s in ['nicht verfügbar', 'nicht genug Daten']
or s.startswith('nicht verfügbar —')
):
# V2 strict mode: missing/unavailable value is not a successful extraction
return None, False
# JSON output type
if output_type == OutputType.JSON:
try:
return json.loads(value_display), True
parsed = json.loads(value_display)
if isinstance(parsed, dict) and parsed.get('_available') is False:
return None, False
return parsed, True
except (json.JSONDecodeError, TypeError):
# Try to find JSON in string
json_match = re.search(r'(\{.*\}|\[.*\])', value_display, re.DOTALL)