{"record":{"id":"a149002701787e65","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"yaml-data-must-be-a-dictionary","errorCode":null,"errorMessage":"YAML data must be a dictionary.","messagePattern":"YAML data must be a dictionary\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":80,"sourceCode":"    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}\")\n            raise TypeError(f\"Error in self_identification data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in self_identification processing: {e}\")\n            raise AttributeError(\"Attribute error in self_identification processing.\") from e\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing self_identification: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing self_identification.\") from e","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L62-L98","documentation":"After successful YAML parsing, the constructor requires the top-level document to be a mapping (dict). If safe_load produced a list, string, number, or None (empty input), a TypeError('YAML data must be a dictionary.') is raised because key-based access like data['self_identification'] would fail.","triggerScenarios":"YAML whose root is a sequence ('- item' lines) or a plain scalar, or an empty/None document (empty file, or content that is only comments).","commonSituations":"YAML file containing only a list of jobs, a file of comments after cleanup, or passing the wrong file entirely (e.g. a plain text file).","solutions":["Ensure the YAML root is a mapping: top-level keys like self_identification, personal_info etc. with nested values, not a top-level list.","Check for an accidentally empty file or one containing only comments.","If you meant to load a list document, wrap it in a dict key first."],"exampleFix":"# before\n# resume.yaml\n- self_identification: ...\n# after\n# resume.yaml\nself_identification:\n  ...  # root must be a mapping","handlingStrategy":"type-guard","validationCode":"import yaml\ndata = yaml.safe_load(text)\nassert isinstance(data, dict), f'YAML root must be a mapping, got {type(data).__name__}'","typeGuard":"def yaml_root_is_mapping(text: str) -> bool:\n    import yaml\n    return isinstance(yaml.safe_load(text), dict)","tryCatchPattern":"try:\n    profile = JobApplicationProfile(text)\nexcept TypeError as e:\n    if 'must be a dictionary' in str(e):\n        raise ConfigError('resume.yaml root must be a mapping') from e\n    raise","preventionTips":["Start resume YAML files with a top-level key, never a list or scalar.","Reject empty files early in your loading code."],"tags":["python","yaml","type-validation","schema"],"backgroundTag":"yaml-schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}