{"record":{"id":"3dcb921320243d59","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"error-parsing-yaml-file","errorCode":null,"errorMessage":"Error parsing YAML file.","messagePattern":"Error parsing YAML file\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":73,"sourceCode":"    salary_range_usd: str\n\n\n@dataclass\nclass JobApplicationProfile:\n    self_identification: SelfIdentification\n    legal_authorization: LegalAuthorization\n    work_preferences: WorkPreferences\n    availability: Availability\n    salary_expectations: SalaryExpectations\n\n    def __init__(self, yaml_str: str):\n        logger.debug(\"Initializing JobApplicationProfile with provided YAML string\")\n        try:\n            data = yaml.safe_load(yaml_str)\n            logger.debug(f\"YAML data successfully parsed: {data}\")\n        except yaml.YAMLError as e:\n            logger.error(f\"Error parsing YAML file: {e}\")\n            raise ValueError(\"Error parsing YAML file.\") from e\n        except Exception as e:\n            logger.error(f\"Unexpected error occurred while parsing the YAML file: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while parsing the YAML file.\") from e\n\n        if not isinstance(data, dict):\n            logger.error(f\"YAML data must be a dictionary, received: {type(data)}\")\n            raise TypeError(\"YAML data must be a dictionary.\")\n\n        # Process self_identification\n        try:\n            logger.debug(\"Processing self_identification\")\n            self.self_identification = SelfIdentification(**data['self_identification'])\n            logger.debug(f\"self_identification processed: {self.self_identification}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in self_identification data.\")\n            raise KeyError(f\"Required field {e} is missing in self_identification data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in self_identification data: {e}\")","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L55-L91","documentation":"JobApplicationProfile parses a YAML string (resume/profile data) with yaml.safe_load in its constructor. If PyYAML raises a YAMLError (syntax problems: bad indentation, tabs, unclosed quotes), it is re-raised as ValueError('Error parsing YAML file.') with the original exception chained.","triggerScenarios":"Passing a malformed YAML string to JobApplicationProfile(yaml_str): tab indentation, missing colons/spaces, unbalanced quotes or brackets, or duplicate keys under strict parsing.","commonSituations":"Hand-editing resume.yaml and breaking indentation, generating YAML from templates with wrong whitespace, or Windows line-ending/tab issues from copy-paste.","solutions":["Read the chained exception (__cause__) or the logged message: it includes PyYAML's line/column of the syntax error.","Validate the YAML with yaml.safe_load in isolation (or a linter like yamllint) before constructing the profile.","Fix indentation (spaces only, no tabs) and quoting in the YAML file."],"exampleFix":"# before\nprofile = JobApplicationProfile(open('resume.yaml').read())  # tabs break it\n# after\nimport yaml\ntext = open('resume.yaml').read()\nyaml.safe_load(text)  # fail fast with line info\nprofile = JobApplicationProfile(text)","handlingStrategy":"validation","validationCode":"import yaml\ntext = open('resume.yaml', encoding='utf-8').read()\nyaml.safe_load(text)  # raises YAMLError with line numbers BEFORE the constructor\nprofile = JobApplicationProfile(text)","typeGuard":null,"tryCatchPattern":"try:\n    profile = JobApplicationProfile(text)\nexcept ValueError as e:\n    if 'Error parsing YAML' in str(e):\n        show_yaml_error(e.__cause__)  # PyYAML marks with line/col\n    else:\n        raise","preventionTips":["Lint YAML files (yamllint) in CI before they reach the app.","Use spaces only (never tabs) and consistent indentation in resume YAML."],"tags":["python","yaml","parsing","config"],"backgroundTag":"yaml-parse-error","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}