{"record":{"id":"75d4e69221666e91","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"required-field-e-is-missing-in-availability-data","errorCode":null,"errorMessage":"Required field {e} is missing in availability data.","messagePattern":"Required field (.+?) is missing in availability data\\.","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":143,"sourceCode":"            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\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","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L125-L161","documentation":"KeyError from the availability section handler in JobApplicationProfile.__init__: raised when 'availability' is absent from the top-level data dict (data['availability'] indexing) or when the Availability constructor is missing a required key and its KeyError propagates. The interpolated {e} names the missing key.","triggerScenarios":"Constructing JobApplicationProfile with a resume dict lacking 'availability', or an availability mapping missing a required field such as 'notice_period'.","commonSituations":"Resume templates that omit availability; sections dropped by cleaning code; newer schema making previously optional availability fields mandatory.","solutions":["Add the missing key named in the message to the resume data.","Default the section when optional: data.setdefault('availability', {}) prior to construction.","Review Availability.__init__ for required fields and ensure the source data provides them."],"exampleFix":"# before\nself.availability = Availability(**data['availability'])\n\n# after\nav = data.get('availability') or {}\nself.availability = Availability(**av)","handlingStrategy":"validation","validationCode":"data.setdefault('availability', {})","typeGuard":"def has_availability(data: dict) -> bool:\n    return isinstance(data.get('availability'), dict)","tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept KeyError as e:\n    if 'availability' in str(e):\n        data.setdefault('availability', {})\n        profile = JobApplicationProfile(**data)","preventionTips":["Treat availability as optional and default it before construction","Validate required nested fields per the schema"],"tags":["python","keyerror","missing-field","availability"],"backgroundTag":"missing-required-field","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}