Skip to content

fix: root_uri() version detection for real OpenStack endpoints#25

Draft
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-root-uri-version-detection
Draft

fix: root_uri() version detection for real OpenStack endpoints#25
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-root-uri-version-detection

Conversation

@Koan-Bot

@Koan-Bot Koan-Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

What

Fix root_uri() in Service.pm returning undef when the OpenStack catalog endpoint URL contains a version path.

Why

Two bugs in line 87 combined to create a silent failure:

  1. Regex too restrictive: m{:[\d]/v} only matched single-digit ports — all real OpenStack endpoints use 4-5 digit ports (:8774, :9696), so the version-detection guard never triggered.
  2. Bare return: Even if the regex matched, return (without $uri) would yield undef, propagating to HTTP methods and causing cryptic errors.

For deployments where the service catalog includes versioned URLs (e.g. http://host:9696/v2.0), services with a version_prefix would generate double-versioned URIs like /v2.0/v2.0/floatingips.

How

  • Changed regex from m{:[\d]/v}a to m{/v\d}a — matches versioned paths regardless of port format or presence.
  • Changed return to return $uri — preserves the URI instead of losing it.

Testing

New t/root-uri.t covering:

  • Endpoint with version path (no prefix added)
  • Endpoint without version (prefix prepended correctly)
  • Versioned endpoint + version_prefix (no double-versioning)
  • URI already starting with v (passthrough)
  • Various endpoint formats (5-digit ports, HTTPS without port, cinder-style paths)
  • Full existing test suite passes with no regressions

Quality Report

Changes: 2 files changed, 127 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

root_uri() line 87 had two bugs that combined to create a silent
failure for OpenStack deployments where catalog endpoints include
version paths (e.g. http://host:9696/v2.0):

1. The regex m{:[\d]/v} only matched single-digit ports — real
   endpoints use 4-5 digit ports like :8774 or :9696, so the
   guard never triggered.

2. On match, bare `return` yielded undef instead of `return $uri`,
   which would propagate undef to HTTP methods causing cryptic errors.

The practical effect: services with both a version_prefix AND a versioned
endpoint (e.g. Network with prefix v2.0 and endpoint .../v2.0) would
produce double-versioned URLs like /v2.0/v2.0/floatingips.

Fix: use m{/v\d}a to match any versioned path regardless of port format,
and return $uri (not undef) so the URI is preserved.

Adds t/root-uri.t with tests covering version detection, prefix behavior,
double-versioning prevention, and various endpoint formats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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