feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · ValueError
Error parsing YAML file.
Error message
Error parsing YAML file.
What it means
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.
Source
Thrown at src/resume_schemas/job_application_profile.py:73
salary_range_usd: str
@dataclass
class JobApplicationProfile:
self_identification: SelfIdentification
legal_authorization: LegalAuthorization
work_preferences: WorkPreferences
availability: Availability
salary_expectations: SalaryExpectations
def __init__(self, yaml_str: str):
logger.debug("Initializing JobApplicationProfile with provided YAML string")
try:
data = yaml.safe_load(yaml_str)
logger.debug(f"YAML data successfully parsed: {data}")
except yaml.YAMLError as e:
logger.error(f"Error parsing YAML file: {e}")
raise ValueError("Error parsing YAML file.") from e
except Exception as e:
logger.error(f"Unexpected error occurred while parsing the YAML file: {e}")
raise RuntimeError("An unexpected error occurred while parsing the YAML file.") from e
if not isinstance(data, dict):
logger.error(f"YAML data must be a dictionary, received: {type(data)}")
raise TypeError("YAML data must be a dictionary.")
# Process self_identification
try:
logger.debug("Processing self_identification")
self.self_identification = SelfIdentification(**data['self_identification'])
logger.debug(f"self_identification processed: {self.self_identification}")
except KeyError as e:
logger.error(f"Required field {e} is missing in self_identification data.")
raise KeyError(f"Required field {e} is missing in self_identification data.") from e
except TypeError as e:
logger.error(f"Error in self_identification data: {e}")View on GitHub (pinned to 79155b52fa)
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.
Example fix
# before
profile = JobApplicationProfile(open('resume.yaml').read()) # tabs break it
# after
import yaml
text = open('resume.yaml').read()
yaml.safe_load(text) # fail fast with line info
profile = JobApplicationProfile(text) Defensive patterns
Strategy: validation
Validate before calling
import yaml
text = open('resume.yaml', encoding='utf-8').read()
yaml.safe_load(text) # raises YAMLError with line numbers BEFORE the constructor
profile = JobApplicationProfile(text) Try / catch
try:
profile = JobApplicationProfile(text)
except ValueError as e:
if 'Error parsing YAML' in str(e):
show_yaml_error(e.__cause__) # PyYAML marks with line/col
else:
raise Prevention
- Lint YAML files (yamllint) in CI before they reach the app.
- Use spaces only (never tabs) and consistent indentation in resume YAML.
When it happens
Trigger: Passing a malformed YAML string to JobApplicationProfile(yaml_str): tab indentation, missing colons/spaces, unbalanced quotes or brackets, or duplicate keys under strict parsing.
Common situations: Hand-editing resume.yaml and breaking indentation, generating YAML from templates with wrong whitespace, or Windows line-ending/tab issues from copy-paste.
Related errors
- Error parsing YAML file.
- Unsupported model type: {llm_model_type}
- Could not extract section name from the response.
- An unexpected error occurred while parsing the YAML file.
- YAML data must be a dictionary.
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/3dcb921320243d59.
Report an issue: GitHub.