feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · RuntimeError

An unexpected error occurred while processing work_preferenc

Error message

An unexpected error occurred while processing work_preferences.

What it means

Catch-all RuntimeError for the work_preferences section of JobApplicationProfile.__init__: any non-KeyError/TypeError/AttributeError raised while constructing WorkPreferences is re-raised under this generic message with the original chained. It masks the real error class (often ValueError from a nested validator), so triage must go through __cause__.

Source

Thrown at src/resume_schemas/job_application_profile.py:134

            raise RuntimeError("An unexpected error occurred while processing legal_authorization.") from e

        # Process work_preferences
        try:
            logger.debug("Processing work_preferences")
            self.work_preferences = WorkPreferences(**data['work_preferences'])
            logger.debug(f"Work_preferences processed: {self.work_preferences}")
        except KeyError as e:
            logger.error(f"Required field {e} is missing in work_preferences data.")
            raise KeyError(f"Required field {e} is missing in work_preferences data.") from e
        except TypeError as e:
            logger.error(f"Error in work_preferences data: {e}")
            raise TypeError(f"Error in work_preferences data: {e}") from e
        except AttributeError as e:
            logger.error(f"Attribute error in work_preferences processing: {e}")
            raise AttributeError("Attribute error in work_preferences processing.") from e
        except Exception as e:
            logger.error(f"An unexpected error occurred while processing work_preferences: {e}")
            raise RuntimeError("An unexpected error occurred while processing work_preferences.") from e

        # Process availability
        try:
            logger.debug("Processing availability")
            self.availability = Availability(**data['availability'])
            logger.debug(f"Availability processed: {self.availability}")
        except KeyError as e:
            logger.error(f"Required field {e} is missing in availability data.")
            raise KeyError(f"Required field {e} is missing in availability data.") from e
        except TypeError as e:
            logger.error(f"Error in availability data: {e}")
            raise TypeError(f"Error in availability data: {e}") from e
        except AttributeError as e:
            logger.error(f"Attribute error in availability processing: {e}")
            raise AttributeError("Attribute error in availability processing.") from e
        except Exception as e:
            logger.error(f"An unexpected error occurred while processing availability: {e}")
            raise RuntimeError("An unexpected error occurred while processing availability.") from e

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Inspect e.__cause__ (and the logged message) to identify the real exception and field.
  2. Test WorkPreferences(**data['work_preferences']) standalone with the failing payload.
  3. Correct the value or loosen the validator; add a specific except clause if the class is now expected.

Example fix

# before
except Exception as e:
    raise RuntimeError("An unexpected error occurred while processing work_preferences.") from e

# after
except ValueError as e:
    raise ValueError(f"Invalid work_preferences value: {e}") from e
except Exception as e:
    raise RuntimeError(f"Unexpected work_preferences failure: {e!r}") from e
Defensive patterns

Strategy: try-catch

Try / catch

try:
    profile = JobApplicationProfile(**data)
except RuntimeError as e:
    if 'work_preferences' in str(e):
        handle(e.__cause__)  # usually ValueError from nested validator

Prevention

When it happens

Trigger: Nested validation inside WorkPreferences raising ValueError (e.g. invalid enum for remote preference), IndexError, or custom exceptions during **-construction.

Common situations: Library/data version mismatch; newly added validations rejecting legacy resume files; custom subclasses that raise domain exceptions.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28). Data as JSON: /api/errors/0e031c6bc5069e48. Report an issue: GitHub.