Hmbown/CodeWhale · error

Session goal objective must contain 1..=

Error message

Session goal objective must contain 1..={MAX_SESSION_GOAL_OBJECTIVE_CHARS} characters

What it means

SessionGoalState::validate requires the trimmed objective to be non-empty and at most MAX_SESSION_GOAL_OBJECTIVE_CHARS characters (counted in chars, not bytes). Objectives outside 1..=MAX chars fail with InvalidData.

Solutions

  1. Shorten the objective in the goal file to within the character limit (keep it a concise goal statement).
  2. Set a non-empty objective if it was blank.
  3. Recreate the goal via the TUI, which enforces the limit at input time.

Example fix

// before: objective is 5000 chars
{"objective": "<entire spec document>", ...}
// after
{"objective": "Implement spec section 3: parser rewrite", ...}
Defensive patterns

Strategy: validation

Validate before calling

fn objective_length_ok(s: &str, max: usize) -> bool {
    let t = s.trim();
    !t.is_empty() && t.chars().count() <= max
}

Try / catch

match load_goal(path) {
    Err(e) if e.to_string().contains("objective must contain") => {
        eprintln!("objective is empty or too long; shorten it in the goal file");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Loading (or validating) a goal state whose objective is empty/whitespace, or whose character count exceeds MAX_SESSION_GOAL_OBJECTIVE_CHARS.

Common situations: Pasting an entire requirements document into the objective; a script dumping long prompts into the goal file; empty objective left by interrupted creation.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/0c9f4dd469ccfb91. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/session_manager.rs:821

            last_gap_pass: snapshot.last_gap_pass,
        };
        state.validate()?;
        Ok(Some(state))
    }

    pub fn validate(&self) -> io::Result<()> {
        if self.schema_version > CURRENT_SESSION_GOAL_SCHEMA_VERSION {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                format!(
                    "Session goal schema v{} is newer than supported v{}",
                    self.schema_version, CURRENT_SESSION_GOAL_SCHEMA_VERSION
                ),
            ));
        }
        let objective = self.objective.trim();
        if objective.is_empty() || objective.chars().count() > MAX_SESSION_GOAL_OBJECTIVE_CHARS {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                format!(
                    "Session goal objective must contain 1..={MAX_SESSION_GOAL_OBJECTIVE_CHARS} characters"
                ),
            ));
        }
        if self
            .goal_id
            .as_ref()
            .is_some_and(|id| id.is_empty() || id.len() > 128)
        {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                "invalid session goal revision",
            ));
        }
        codewhale_protocol::validate_goal_stall_state(
            self.last_gap_fingerprint.as_deref(),

View on GitHub (pinned to 73e0f67d83)