feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError

Attribute error in salary_expectations processing.

Error message

Attribute error in salary_expectations processing.

What it means

AttributeError from the salary_expectations try block in JobApplicationProfile.__init__: an attribute/method access on a wrongly-typed nested value (None/str/int where a dict or object is expected) inside SalaryExpectations construction is caught and re-raised with this static message. The chained __cause__ and the logger.error output carry the actual attribute name.

Source

Thrown at src/resume_schemas/job_application_profile.py:167

            raise AttributeError("Attribute error in availability processing.") from e
        except Exception as e:
            logger.error(f"An unexpected error occurred while processing availability: {e}")
            raise RuntimeError("An unexpected error occurred while processing availability.") from e

        # Process salary_expectations
        try:
            logger.debug("Processing salary_expectations")
            self.salary_expectations = SalaryExpectations(**data['salary_expectations'])
            logger.debug(f"salary_expectations processed: {self.salary_expectations}")
        except KeyError as e:
            logger.error(f"Required field {e} is missing in salary_expectations data.")
            raise KeyError(f"Required field {e} is missing in salary_expectations data.") from e
        except TypeError as e:
            logger.error(f"Error in salary_expectations data: {e}")
            raise TypeError(f"Error in salary_expectations data: {e}") from e
        except AttributeError as e:
            logger.error(f"Attribute error in salary_expectations processing: {e}")
            raise AttributeError("Attribute error in salary_expectations processing.") from e
        except Exception as e:
            logger.error(f"An unexpected error occurred while processing salary_expectations: {e}")
            raise RuntimeError("An unexpected error occurred while processing salary_expectations.") from e

        logger.debug("JobApplicationProfile initialization completed successfully.")

    def __str__(self):
        logger.debug("Generating string representation of JobApplicationProfile")

        def format_dataclass(obj):
            return "\n".join(f"{field.name}: {getattr(obj, field.name)}" for field in obj.__dataclass_fields__.values())

        formatted_str = (f"Self Identification:\n{format_dataclass(self.self_identification)}\n\n"
                         f"Legal Authorization:\n{format_dataclass(self.legal_authorization)}\n\n"
                         f"Work Preferences:\n{format_dataclass(self.work_preferences)}\n\n"
                         f"Availability: {self.availability.notice_period}\n\n"
                         f"Salary Expectations: {self.salary_expectations.salary_range_usd}\n\n")
        logger.debug(f"String representation generated: {formatted_str}")

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Inspect e.__cause__ or logs for the failing attribute.
  2. Coerce None/scalar nested values to the expected shapes before constructing the profile.
  3. Default problematic nested fields or make SalaryExpectations defensive about optional sub-objects.

Example fix

# before
se = data['salary_expectations']  # {'range': None}
self.salary_expectations = SalaryExpectations(**se)

# after
se = {k: (v if v is not None else {}) for k, v in (data.get('salary_expectations') or {}).items()}
self.salary_expectations = SalaryExpectations(**se)
Defensive patterns

Strategy: validation

Validate before calling

se = data.get('salary_expectations') or {}
se = {k: (v if v is not None else {}) for k, v in se.items()}

Type guard

def salary_fields_valid(se) -> bool:
    return isinstance(se, dict) and all(v is None or isinstance(v, (dict, list, str, int)) for v in se.values())

Try / catch

try:
    profile = JobApplicationProfile(**data)
except AttributeError as e:
    if 'salary_expectations' in str(e):
        log.error('attr cause: %r', e.__cause__)

Prevention

When it happens

Trigger: Nested salary fields (e.g. a range or currency object) being None or a scalar while the constructor calls .get()/.lower()/etc. on them.

Common situations: Sparse resumes with null salary sections; data producers with inconsistent types; refactors changing nested salary structures from scalars to objects.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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