Skip to content

fix: strict RFC 4122 UUID validation in *_from_uid methods#10

Draft
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/strict-uuid-validation
Draft

fix: strict RFC 4122 UUID validation in *_from_uid methods#10
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/strict-uuid-validation

Conversation

@Koan-Bot

@Koan-Bot Koan-Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

What

Enforce strict 8-4-4-4-12 hex UUID format validation at server_from_uid(), image_from_uid(), and all spec-generated getfromid entry points.

Why

The loose qr{^[a-f0-9\-]+$}i regex accepted any mix of hex and dashes — strings like "aaa", "---", or "abc-def" passed validation and were sent to the OpenStack API, producing cryptic remote 404/400 errors instead of a clear local error message.

How

  • Added strict RFC 4122 regex (^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$) in GetFromId.pm (_get_from_id and _get_from_id_spec) and Images.pm (image_from_uid)
  • Kept _looks_valid_id() in MetaAPI.pm as a loose heuristic — it's used for ID-vs-name routing and must accept non-UUID IDs (e.g., numeric flavor IDs like "1", "2")
  • Fixed test fixture UUIDs that used non-compliant formats (e.g., 000000-1111-22222-33333-44444400000000-1111-2222-3333-444444444444)
  • Added 9 new tests verifying malformed UUID rejection for both server_from_uid and image_from_uid

Testing

Full test suite passes: 32 tests across 6 files.

🤖 Generated with Claude Code


Quality Report

Changes: 7 files changed, 76 insertions(+), 23 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Malformed UUIDs (e.g. "aaa-bbb", "not-a-uuid") were silently passed
to the OpenStack API, producing cryptic 404 or 400 errors. Now
server_from_uid(), image_from_uid(), and all spec-generated getfromid
methods validate input against the 8-4-4-4-12 hex format before
making any API call, with a clear die message.

The _looks_valid_id() heuristic is intentionally left loose — it
serves as an ID-vs-name routing check, and OpenStack resources like
flavors use simple numeric IDs. Strict UUID validation is applied
at the entry points where UUIDs are the expected format.

Test fixture UUIDs that used non-compliant formats have been
corrected to proper 8-4-4-4-12 format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot
Koan-Bot force-pushed the koan.atoomic/strict-uuid-validation branch from 2f4b548 to 87800fd Compare April 20, 2026 13:22
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.

1 participant