Skip to content

fix(classify-hardware): guard non-numeric and negative bounds in ram and vram parsing - #6084

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/classify-hardware-numeric-bounds
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/classify-hardware-numeric-bounds

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/scripts/classify-hardware.sh, --vram-mb and --ram-mb CLI arguments were converted directly in Python using int(float(sys.argv[...] or 0)). When upstream hardware detection probes fail to detect a GPU or memory module (or return non-numeric placeholders like "None", "N/A", or "null"), Python raised an unhandled ValueError: could not convert string to float: 'None'. This aborted hardware classification, causing installer and preflight routines to crash instead of falling back to default CPU profile recommendations.

This change introduces a safe numeric parsing helper _safe_mb that catches ValueError and TypeError, safely defaults invalid or empty inputs to 0, and clamps negative values to non-negative bounds (max(0, ...)). All hardware matching logic, overlay mappings, and output JSON schemas remain unchanged.

Validation

  • Baseline reproduction: Executing classify-hardware.sh --vram-mb None --ram-mb N/A raised ValueError: could not convert string to float: 'None' and exited with status 1.
  • Post-fix verification: Running ods/tests/test_classify_hardware_numeric_bounds.py validates that non-numeric strings ("None", "N/A", "null"), negative numbers, and float representations execute cleanly with exit code 0 and emit valid hardware classification recommendations.
  • Telemetry: Hardware compatibility test suite: test_classify_hardware_numeric_bounds.py passes cleanly (exit code 0). Wired into Linux CI workflow under Manifest Compatibility Checks.

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation, and test regressions. This strengthens numeric CLI argument parsing in classify-hardware.sh. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #6076, #6077, #6078, #6079, #6080, #6081, #6082, and #6083 at HEAD without conflicts. Production and test diffs passed together; hardware classification and manifest checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants