{"record":{"id":"967743e4a48f0b5e","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"required-field-e-is-missing-in-salary-expectatio","errorCode":null,"errorMessage":"Required field {e} is missing in salary_expectations data.","messagePattern":"Required field (.+?) is missing in salary_expectations data\\.","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":161,"sourceCode":"            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\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","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L143-L179","documentation":"KeyError raised from the salary_expectations block of JobApplicationProfile.__init__: the top-level 'salary_expectations' key is absent (dict indexing), or the SalaryExpectations constructor requires a field (e.g. 'currency' or 'amount') that the nested dict lacks and its KeyError propagates here. The missing key name is embedded in the message.","triggerScenarios":"JobApplicationProfile(**data) with no 'salary_expectations' in data, or a salary dict missing a field SalaryExpectations declares as required.","commonSituations":"Candidates omitting salary expectations from resumes; pipelines dropping empty sections; schema changes promoting optional salary fields to required.","solutions":["Add the missing key named in the message (top-level key or nested field).","Default the section if optional: data.setdefault('salary_expectations', {}) before construction.","Inspect SalaryExpectations.__init__ to see mandatory fields and fill them from source data."],"exampleFix":"# before\nself.salary_expectations = SalaryExpectations(**data['salary_expectations'])\n\n# after\nse = data.get('salary_expectations') or {}\nself.salary_expectations = SalaryExpectations(**se)","handlingStrategy":"validation","validationCode":"data.setdefault('salary_expectations', {})","typeGuard":"def has_salary_expectations(data: dict) -> bool:\n    return isinstance(data.get('salary_expectations'), dict)","tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept KeyError as e:\n    if 'salary_expectations' in str(e):\n        data.setdefault('salary_expectations', {})\n        profile = JobApplicationProfile(**data)","preventionTips":["Default optional salary section to {}","Ensure required nested salary fields are populated when the section is present"],"tags":["python","keyerror","missing-field","salary-expectations"],"backgroundTag":"missing-required-field","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}