Skip to content

fix: register exception handlers and fix handle_plural_values() white spaces#306

Open
vidhip222 wants to merge 1 commit intofireform-core:mainfrom
vidhip222:283-refactor-handle-plural-values
Open

fix: register exception handlers and fix handle_plural_values() white spaces#306
vidhip222 wants to merge 1 commit intofireform-core:mainfrom
vidhip222:283-refactor-handle-plural-values

Conversation

@vidhip222
Copy link

@vidhip222 vidhip222 commented Mar 21, 2026

Two bug fixes to the LLM data extraction pipeline and API error handling.

  1. src/llm.py: Fix whitespace stripping in handle_plural_values()
    The previous loop started at index i+1, leaving values[0] (the first LLM-extracted value) never stripped. It also only applied lstrip(), missing trailing whitespace. Replaced with a list comprehension using str.strip() that correctly cleans all values and filters out empty entries from trailing semicolons. Also adds type hints (str -> list[str]) and fixes a typo in the log message.
  2. api/main.py: Register custom exception handlers
    Register_exception_handlers() was defined in api/errors/handlers.py but never called on app startup, so AppError exceptions (e.g. 404 for missing templates) were unhandled by FastAPI and returned as 500 errors instead of the intended status codes.

Issues:
Fixes #283
Fixes #295

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Manually verified handle_plural_values() edge cases: leading whitespace, trailing whitespace, trailing semicolons, normal input
  • Verified AppError with 404 status now returns correct response instead of 500

Test Configuration:

  • Python: 3.x
  • OS: Windows 11

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Register Custom Exception Handlers in FastAPI App Refactor handle_plural_values() to simplify whitespace handling when parsing plural values

1 participant