Skip to content

app.memoryBudget takes a non-number mb as "report only" #3706

Open

Description

@THEtheChad

app.memoryBudget reads its one parameter with p.get("mb").and_then(Value::as_f64) (crates/engine/src/cmd/query.rs:268, on main since 7266f41). An mb that is present but isn't a JSON number ({"mb": "512"}, {"mb": true}, {"mb": [512]}) goes down the same path as a missing one: the command succeeds, returns the memory report, and doesn't change the budget.

Why it matters

A caller over the control channel, MCP or the CLI that sends the number as a string (a common slip from scripts and agents) gets a success reply and thinks the budget changed. Only a careful reading of the budget field in the report shows it didn't. Other commands refuse a mistyped parameter instead: photo_id (crates/engine/src/cmd.rs:228) refuses {"id": "5"}, and denoise.settings refuses a cacheGb that isn't a whole number. An out-of-range number ({"mb": 10}) is already refused here.

What a fix needs

  • A present, non-null mb that isn't a number is refused with the command's BadParams error, naming the expected values (a number of megabytes from 64 to 1048576).
  • Missing or null mb keeps today's behaviour: the report only.
  • Numbers keep today's behaviour: 64..1048576 sets the budget, anything else (0 included) is refused.
  • Tests: string, bool and array mb are refused; null and missing return the report; 0 is refused as out of range; a valid number still sets the budget.

PR #3118 (open, #3072) makes mb: 0 mean "automatic" in the same block. This fix touches the same lines, so whichever lands second needs a small rebase.

Activity

  1. ticket-craft commented on Nov 3, 2026

    @ticket-craft

    Possibly related: #181, #2625 and #2097.

  2. added 8 commits that reference this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automationbugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions