can1357/oh-my-pi · error · HTTPException

missing/invalid 'slot_uid'

Error message

missing/invalid 'slot_uid'

What it means

The gh-proxy validates the optional `slot_uid` body/query parameter with `_optional_slot_uid`. If supplied, it must be a strict integer strictly between 0 and 65536 (booleans rejected). Any missing-or-invalid value raises this HTTP 400 before the request reaches the git push logic.

Source

Thrown at python/robomp/src/proxy/server.py:168

    branch = _require_fetch_ref(value)
    return branch.removeprefix("refs/heads/")


_RELEASE_TAG_RE = re.compile(r"v[0-9][A-Za-z0-9._-]*")


def _require_release_tag(value: Any) -> str:
    tag = _require_str(value, "tag")
    if not _RELEASE_TAG_RE.fullmatch(tag):
        raise HTTPException(400, "invalid tag")
    return tag


def _optional_slot_uid(value: Any) -> int | None:
    if value is None:
        return None
    if not isinstance(value, int) or isinstance(value, bool) or not (0 < value < 65536):
        raise HTTPException(400, "missing/invalid 'slot_uid'")
    return value


def _optional_str_list(value: Any, field: str) -> list[str] | None:
    if value is None:
        return None
    if not isinstance(value, list) or not all(isinstance(v, str) for v in value):
        raise HTTPException(400, f"invalid '{field}': must be array of strings")
    return list(value)


def _require_review_comments(value: Any) -> list[dict[str, Any]]:
    if value is None:
        return []
    if not isinstance(value, list):
        raise HTTPException(400, "missing/invalid 'comments'")
    comments: list[dict[str, Any]] = []
    for idx, item in enumerate(value):

View on GitHub (pinned to 9690622007)

Solutions

  1. Send `slot_uid` as a JSON number in the range 1..65535 (e.g. 42, not "42"), or omit the field entirely if no slot is targeted.
  2. On the client, coerce with care: `slot_uid = int(raw)` and re-check `0 < slot_uid < 65536` before sending.
  3. Remove `true`/`false` values — Python's isinstance(value, bool) check rejects them even though bool subclasses int.
  4. If the field is not needed by your flow, drop it from the payload instead of sending null-come-string placeholders.

Example fix

// before
curl -X POST .../git/push -d '{"slot_uid": "12", ...}'
// after
curl -X POST .../git/push -d '{"slot_uid": 12, ...}'
Defensive patterns

Strategy: validation

Validate before calling

def valid_slot_uid(v):
    return isinstance(v, int) and not isinstance(v, bool) and 0 < v < 65536

payload = {"slot_uid": int(cfg.slot_id)} if valid_slot_uid(cfg.slot_id) else {}

Type guard

def is_slot_uid(v: object) -> TypeGuard[int]:
    return isinstance(v, int) and not isinstance(v, bool) and 0 < v < 65536

Try / catch

try:
    resp = http.post(f"{base}/git/push", json=payload)
    resp.raise_for_status()
except httpx.HTTPStatusError as e:
    if e.response.status_code == 400 and "slot_uid" in e.response.text:
        raise ValueError("slot_uid must be an int in 1..65535") from e
    raise

Prevention

When it happens

Trigger: Calling git_push_endpoint or git_push_release_endpoint with `slot_uid` set to a bool (true/false), a string like "12", a float, a negative number, 0, or an integer >= 65536.

Common situations: Clients JSON-encode slot ids as strings from config files or environment variables; frontends send booleans because slot ids are modeled as flags; ids out of the 16-bit port-like range are used by custom sandbox allocators.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/66eaf61ff6829d2b. Report an issue: GitHub.