Skip to content

fix(obs-studio): reject non-finite geometry in source transforms#397

Open
santhreal wants to merge 3 commits into
HKUDS:mainfrom
santhreal:fix/obs-validate-pos-size-nan
Open

fix(obs-studio): reject non-finite geometry in source transforms#397
santhreal wants to merge 3 commits into
HKUDS:mainfrom
santhreal:fix/obs-validate-pos-size-nan

Conversation

@santhreal

Copy link
Copy Markdown

Problem

add_source / transform_source accepted NaN position coordinates into project JSON. Size/crop hit cryptic int(NaN) errors instead of a clear validation failure.

Repro

from cli_anything.obs_studio.core.sources import transform_source

transform_source(project, 0, position={"x": float("nan")})
# unpatched: writes nan into source["position"]["x"]

Fix

Validate position/size/crop with math.isfinite and call those helpers from the live source paths (complements #396 which covers validate_range only).

validate_position accepted NaN coordinates into project JSON. size/crop
converted NaN via int() with a cryptic error. Reject non-finite values
up front, matching validate_range.
validate_position/size/crop were unused while add_source and
transform_source accepted NaN into project JSON. Call the validators
from those paths and cover the live transform entrypoint.
@github-actions github-actions Bot added the existing-cli-fix Fixes or improves an existing CLI harness label Jul 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 516177b974

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"""Validate and normalize a size dict."""
w = int(size.get("width", 1920))
h = int(size.get("height", 1080))
width_raw = float(size.get("width", 1920))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve integer geometry without float rounding

For finite integer dimensions above IEEE-754's exact range, this new intermediate float conversion silently changes the requested geometry before int restores it: for example, width=2**53 + 1 is stored as 2**53, whereas the previous implementation preserved the integer exactly. This affects API callers and CLI-parsed integer sizes, and the identical conversion in validate_crop corrupts large crop values as well; validate finiteness without routing already-integral inputs through float.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

existing-cli-fix Fixes or improves an existing CLI harness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant