{"record":{"id":"0e031c6bc5069e48","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"an-unexpected-error-occurred-while-processing-work","errorCode":null,"errorMessage":"An unexpected error occurred while processing work_preferences.","messagePattern":"An unexpected error occurred while processing work_preferences\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":134,"sourceCode":"            raise RuntimeError(\"An unexpected error occurred while processing legal_authorization.\") from e\n\n        # Process work_preferences\n        try:\n            logger.debug(\"Processing work_preferences\")\n            self.work_preferences = WorkPreferences(**data['work_preferences'])\n            logger.debug(f\"Work_preferences processed: {self.work_preferences}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in work_preferences data.\")\n            raise KeyError(f\"Required field {e} is missing in work_preferences data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in work_preferences data: {e}\")\n            raise TypeError(f\"Error in work_preferences data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in work_preferences processing: {e}\")\n            raise AttributeError(\"Attribute error in work_preferences processing.\") from e\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing work_preferences: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing work_preferences.\") from e\n\n        # Process availability\n        try:\n            logger.debug(\"Processing availability\")\n            self.availability = Availability(**data['availability'])\n            logger.debug(f\"Availability processed: {self.availability}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in availability data.\")\n            raise KeyError(f\"Required field {e} is missing in availability data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in availability data: {e}\")\n            raise TypeError(f\"Error in availability data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in availability processing: {e}\")\n            raise AttributeError(\"Attribute error in availability processing.\") from e\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing availability: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing availability.\") from e","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L116-L152","documentation":"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__.","triggerScenarios":"Nested validation inside WorkPreferences raising ValueError (e.g. invalid enum for remote preference), IndexError, or custom exceptions during **-construction.","commonSituations":"Library/data version mismatch; newly added validations rejecting legacy resume files; custom subclasses that raise domain exceptions.","solutions":["Inspect e.__cause__ (and the logged message) to identify the real exception and field.","Test WorkPreferences(**data['work_preferences']) standalone with the failing payload.","Correct the value or loosen the validator; add a specific except clause if the class is now expected."],"exampleFix":"# before\nexcept Exception as e:\n    raise RuntimeError(\"An unexpected error occurred while processing work_preferences.\") from e\n\n# after\nexcept ValueError as e:\n    raise ValueError(f\"Invalid work_preferences value: {e}\") from e\nexcept Exception as e:\n    raise RuntimeError(f\"Unexpected work_preferences failure: {e!r}\") from e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept RuntimeError as e:\n    if 'work_preferences' in str(e):\n        handle(e.__cause__)  # usually ValueError from nested validator","preventionTips":["Unit-test WorkPreferences with boundary values","Log __cause__ to triage quickly","Version-resume fixture tests"],"tags":["python","runtime-error","work-preferences","constructor"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}