From d18d5047b3fd1a5694aea394916709a8475f49c0 Mon Sep 17 00:00:00 2001 From: Stephan Krinetzki Date: Mon, 23 Mar 2026 14:53:49 +0100 Subject: [PATCH] fix: search_handler yields bytes and handle None in entity_extended_display - search_handler yielded str from dumps() instead of bytes, causing TypeError in gunicorn when streaming search results - entity_extended_display could return None for display/info causing AttributeError on .strip() when searching for SPs Tested on pyFF 2.1.5 with gunicorn 25.1.0 and Python 3.12 --- src/pyff/api.py | 2 +- src/pyff/samlmd.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyff/api.py b/src/pyff/api.py index 10e7b3ad..4068b94f 100644 --- a/src/pyff/api.py +++ b/src/pyff/api.py @@ -462,7 +462,7 @@ def _response() -> Generator[bytes, bytes, None]: for e in entities: if in_loop: yield b',' - yield dumps(e) + yield dumps(e).encode('utf-8') in_loop = True yield b']' diff --git a/src/pyff/samlmd.py b/src/pyff/samlmd.py index b23f41b4..68700178 100644 --- a/src/pyff/samlmd.py +++ b/src/pyff/samlmd.py @@ -841,7 +841,7 @@ def entity_extended_display(entity, langs=None): if info == entity.get('entityID'): info = '' - return display.strip(), info.strip() + return (display or '').strip(), (info or '').strip() def entity_display_name(entity: Element, langs=None) -> str: