{"record":{"id":"b552e2c7fa1b4e5e","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"an-unexpected-error-occurred-while-processing-sala","errorCode":null,"errorMessage":"An unexpected error occurred while processing salary_expectations.","messagePattern":"An unexpected error occurred while processing salary_expectations\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":170,"sourceCode":"            raise RuntimeError(\"An unexpected error occurred while processing availability.\") from e\n\n        # Process salary_expectations\n        try:\n            logger.debug(\"Processing salary_expectations\")\n            self.salary_expectations = SalaryExpectations(**data['salary_expectations'])\n            logger.debug(f\"salary_expectations processed: {self.salary_expectations}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in salary_expectations data.\")\n            raise KeyError(f\"Required field {e} is missing in salary_expectations data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in salary_expectations data: {e}\")\n            raise TypeError(f\"Error in salary_expectations data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in salary_expectations processing: {e}\")\n            raise AttributeError(\"Attribute error in salary_expectations processing.\") from e\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing salary_expectations: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing salary_expectations.\") from e\n\n        logger.debug(\"JobApplicationProfile initialization completed successfully.\")\n\n    def __str__(self):\n        logger.debug(\"Generating string representation of JobApplicationProfile\")\n\n        def format_dataclass(obj):\n            return \"\\n\".join(f\"{field.name}: {getattr(obj, field.name)}\" for field in obj.__dataclass_fields__.values())\n\n        formatted_str = (f\"Self Identification:\\n{format_dataclass(self.self_identification)}\\n\\n\"\n                         f\"Legal Authorization:\\n{format_dataclass(self.legal_authorization)}\\n\\n\"\n                         f\"Work Preferences:\\n{format_dataclass(self.work_preferences)}\\n\\n\"\n                         f\"Availability: {self.availability.notice_period}\\n\\n\"\n                         f\"Salary Expectations: {self.salary_expectations.salary_range_usd}\\n\\n\")\n        logger.debug(f\"String representation generated: {formatted_str}\")\n        return formatted_str\n","sourceCodeStart":152,"sourceCodeEnd":187,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L152-L187","documentation":"Catch-all RuntimeError for the salary_expectations section — the last section processed before 'JobApplicationProfile initialization completed successfully' is logged. Any exception other than KeyError/TypeError/AttributeError raised while constructing SalaryExpectations is wrapped as this message, with the original chained. Because it aborts the very end of __init__, earlier sections were already set on the instance but the object is still not returned.","triggerScenarios":"Nested validators inside SalaryExpectations raising ValueError (e.g. unparseable currency code or numeric range), IndexError, or custom exceptions during **-construction.","commonSituations":"Salary stored as a formatted string ('$80,000') that fails numeric coercion; stricter validation after a library upgrade; heterogeneous data sources.","solutions":["Read e.__cause__ to find the underlying exception and field.","Isolate by constructing SalaryExpectations(**data['salary_expectations']) with the same payload.","Sanitize the value (parse numbers, normalize currency codes) or add a targeted except clause for the real type."],"exampleFix":"# before\nexcept Exception as e:\n    raise RuntimeError(\"An unexpected error occurred while processing salary_expectations.\") from e\n\n# after\nexcept ValueError as e:\n    raise ValueError(f\"Invalid salary_expectations: {e}\") from e\nexcept Exception as e:\n    raise RuntimeError(f\"Unexpected salary_expectations failure: {e!r}\") from e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept RuntimeError as e:\n    if 'salary_expectations' in str(e):\n        handle(e.__cause__)","preventionTips":["Sanitize salary strings ('80,000' -> 80000) before loading","Pin library versions","Log chained causes"],"tags":["python","runtime-error","salary-expectations","constructor"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}