Hmbown/CodeWhale · error · Error

No pet segment was prepared.

Error message

No pet segment was prepared.

What it means

The `browser` tool's `start` action accepts an optional `url`, which must be a string when present. Since the URL is optional (null/undefined is allowed), only a present-but-wrong-type value — number, object, boolean, etc. — throws this error.

Solutions

  1. Pass the url as a string, e.g. "https://example.com", or omit it to start with the default page.
  2. Coerce values with String(url) only if you are sure the value is URL-like; otherwise fix the source of the value.
  3. If the value came from parsed config/CLI input, validate it is typeof string before calling.

Example fix

// before
resolveTool("browser", { action: "start", url: 8080 });
// after
resolveTool("browser", { action: "start", url: "http://localhost:8080" });
Defensive patterns

Strategy: type-guard

Validate before calling

if (args.url != null && typeof args.url !== "string") {
  throw new Error("browser start url must be a string when provided");
}

Type guard

const hasValidStartUrl = (a) => a.url == null || typeof a.url === "string";

Prevention

When it happens

Trigger: resolveTool("browser", {action:"start", url: 8080}) or url: {host:"example.com"} or url: true — any non-null, non-string url passed to browser start.

Common situations: Passing a port number instead of a URL string; building args programmatically and assigning an object; a model emitting url as a structured {protocol,host} object; config where url comes from a numeric env var.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/tui/pet_watch/pet-native.js:66

    }
    /** Losing a producer invalidates outstanding coverage, never the creature. */
    disconnectEngine() { this.engine = new pet_engine_js_1.PetEngineTelemetry(); this.world.voices = []; }
    interact(kind, x, y) { this.world.interact(kind, x, y); }
    interactions() { return JSON.stringify(this.world.interactions); }
    accept(packet) { this.world.acceptTelemetry(JSON.parse(packet)); }
    acceptLiveTail(text) {
        const packet = this.liveTape.readTail(text);
        if (!packet)
            return false;
        this.world.acceptTelemetry(packet);
        return true;
    }
    resetLiveInput() { this.liveTape.reset(); return this.resumeEngine(); }
    recording(withCheckpoint = false) { return JSON.stringify(this.world.recording(withCheckpoint)); }
    needsSegment() { return this.world.needsSegment; }
    prepareSegment() { this.segment = this.world.prepareSegment(); return JSON.stringify(this.segment.recording); }
    commitSegment() { if (!this.segment)
        throw new Error('No pet segment was prepared.'); this.segment.commit(); this.segment = undefined; }
    checkpoint() { return JSON.stringify(this.world.checkpoint()); }
    recordingChunk(index, completed = false) { return this.world.recordingChunk(index, completed); }
    restoreCheckpoint(text) {
        if (text.length > 512 * 1024)
            throw new Error('Pet checkpoint exceeds its size limit.');
        this.restoreRecording(JSON.stringify({ ...this.world.recording(false), checkpoint: JSON.parse(text) }));
    }
    restoreRecording(text) {
        if (text.length > 8 * 1024 * 1024)
            throw new Error('Native habitat exceeds 8 MiB.');
        const points = this.world.sim.p.map(p => [p.hx, p.hy]);
        this.world = pet_world_js_1.PetWorld.fromRecording(points, JSON.parse(text));
        this.liveTape.reset();
        this.segment = undefined;
        this.engineTick = Math.round(this.world.frame.timeMs * 30 / 1000);
        this.engine = new pet_engine_js_1.PetEngineTelemetry();
    }
    /** Resume a live host at the first unrecorded bucket. Keep every accepted

View on GitHub (pinned to 73e0f67d83)