{"record":{"id":"0f272f33b02bf668","repo":"langchain-ai/deepagents","slug":"goal-application-requires-a-non-empty-objective-an","errorCode":null,"errorMessage":"goal application requires a non-empty objective and rubric","messagePattern":"goal application requires a non-empty objective and rubric","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/app.py","lineNumber":2349,"sourceCode":"    def __post_init__(self) -> None:\n        \"\"\"Reject an empty or oversized objective or rubric at construction.\n\n        Callers already screen these (`_accept_goal_rubric`), so this guards\n        against a future construction site skipping that check — queuing a goal\n        that would clear the active one to nothing, or one whose text cannot\n        render as a goal-state notice. Holding both invariants here means they\n        do not depend on every construction site remembering; callers keep their\n        own checks so they can report a targeted message before mutating UI\n        state.\n\n        Raises:\n            ValueError: If `objective` or `rubric` is empty.\n            GoalStateSizeError: If either exceeds its own limit, or their\n                combined text exceeds `GOAL_APPLICATION_CHAR_LIMIT`.\n        \"\"\"  # noqa: DOC502 - propagates from `validate_goal_application`\n        if not self.objective or not self.rubric:\n            msg = \"goal application requires a non-empty objective and rubric\"\n            raise ValueError(msg)\n        validate_goal_application(self.objective, self.rubric)\n\n\n@dataclass(frozen=True, slots=True)\nclass _GoalApplicationResult:\n    \"\"\"Applied goal transition and whether its checkpoint write succeeded.\"\"\"\n\n    transition: Literal[\"create\", \"amended\"]\n    persisted: bool\n\n\n@dataclass(frozen=True, slots=True)\nclass _BlockedGoalResetResult:\n    \"\"\"Blocked-goal reset outcome used to gate the following user turn.\n\n    Build instances through `proceed`, `reset`, or `failed` so only valid\n    field combinations are constructed. `did_reset` — not a `blocker_note`\n    sentinel — is the authoritative signal that a blocked goal was flipped","sourceCodeStart":2331,"sourceCodeEnd":2367,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/app.py#L2331-L2367","documentation":"A goal application (objective + rubric pair) was constructed with an empty `objective` or `rubric`. The dataclass `__post_init__` enforces that both fields are non-empty before delegating to `validate_goal_application` for size limits, failing fast on structurally useless goal definitions.","triggerScenarios":"Constructing the goal-application dataclass with `objective=''`, `rubric=''`, or None — typically from empty form fields, a config file with blank keys, or a programmatic call that passed unvalidated user input.","commonSituations":"Automation that builds goals from config/templates where a placeholder was never filled; user submitted a goal form with one field blank.","solutions":["Supply a non-empty objective and a non-empty rubric before constructing the object","Strip whitespace and reject empty strings at the input boundary","If a goal is genuinely absent, skip construction instead of passing empty strings"],"exampleFix":"// before\nGoalApplication(objective=\"\", rubric=\"answer correctly\")\n// after\nif not objective.strip() or not rubric.strip():\n    raise ValueError(\"objective and rubric are required\")\nGoalApplication(objective=objective, rubric=rubric)","handlingStrategy":"validation","validationCode":"if not objective or not objective.strip() or not rubric or not rubric.strip():\n    raise ValueError(\"goal application requires a non-empty objective and rubric\")","typeGuard":"def has_goal_fields(goal: object) -> bool:\n    return (\n        isinstance(goal, GoalApplication)\n        and bool(goal.objective)\n        and bool(goal.rubric)\n    )","tryCatchPattern":"try:\n    goal = GoalApplication(objective=obj, rubric=rub)\nexcept ValueError as exc:\n    logger.warning(\"invalid goal: %s\", exc)\n    return None","preventionTips":["Strip and check text fields at the input/UI boundary","Treat whitespace-only strings as empty","Skip goal construction entirely when a field is genuinely absent","Test config-loading paths with blank template fields"],"tags":["validation","dataclass","goal-state"],"backgroundTag":"missing-required-field","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}