feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError

AttributeError in Experience: {e}

Error message

AttributeError in Experience: {e}

What it means

An AttributeError escaped the per-entry experience processing — most commonly because `exp` (or a nested value like a responsibility item) is not the expected dict/object, so .get()/attribute access fails. The chained original names the attribute and the actual type.

Source

Thrown at src/resume_schemas/resume.py:184

                    for resp in exp.get('key_responsibilities', [])
                ]
                skills_acquired = [str(skill) for skill in exp.get('skills_acquired', [])]
                experience = ExperienceDetails(
                    position=exp['position'],
                    company=exp['company'],
                    employment_period=exp['employment_period'],
                    location=exp['location'],
                    industry=exp['industry'],
                    key_responsibilities=key_responsibilities,
                    skills_acquired=skills_acquired
                )
                experience_list.append(experience)
            except KeyError as e:
                raise KeyError(f"Missing field in experience details: {e}") from e
            except TypeError as e:
                raise TypeError(f"Invalid data for Experience: {e}") from e
            except AttributeError as e:
                raise AttributeError(f"AttributeError in Experience: {e}") from e
            except Exception as e:
                raise Exception(f"Unexpected error in Experience processing: {e}") from e
        return experience_list


@dataclass
class Exam:
    name: str
    grade: str

@dataclass
class Responsibility:
    description: str

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Inspect e.__cause__ to find the offending object and type.
  2. Normalize the list: entries = [e if isinstance(e, dict) else {} for e in data], or skip invalid entries with a warning.
  3. Add type checks on nested values before attribute/method use.

Example fix

// before
for exp in data:
    industry = exp['industry']

# after
for exp in data:
    if not isinstance(exp, dict):
        logger.warning('skipping non-dict experience entry: %r', exp)
        continue
    industry = exp.get('industry')
Defensive patterns

Strategy: type-guard

Validate before calling

data = [e for e in data if isinstance(e, dict)]

Type guard

def is_experience_list(x: Any) -> TypeGuard[list[dict]]:
    return isinstance(x, list) and all(isinstance(e, dict) for e in x)

Try / catch

try:
    exp_list = _process_experience_details(data)
except AttributeError as e:
    logger.warning("malformed experience entry (%s); skipping", e)
    exp_list = []

Prevention

When it happens

Trigger: for exp in data where an entry is a string or None → "'str' object has no attribute 'get'"; nested dict expected but a scalar supplied for company/skills.

Common situations: Mixed extraction output (free-text blurbs mixed with structured entries); nulls in JSON arrays; API returning objects where the code assumes dicts.

Related errors


AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28). Data as JSON: /api/errors/52bff4d90ce69157. Report an issue: GitHub.