Skip to content

fix: reject a Helm location with no chart name at load time (closes #620) - #630

Merged
fatih-acar merged 2 commits into
developfrom
ai-bug-pipeline-620-helm-location-no-chart-name-5e96ebcddc3d8bbd
Nov 30, 2026
Merged

fatih-acar merged 2 commits into
developfrom
ai-bug-pipeline-620-helm-location-no-chart-name-5e96ebcddc3d8bbd

Conversation

@opsmill-bug-pipeline

@opsmill-bug-pipeline opsmill-bug-pipeline Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Analyst's findings (summary)

Root cause: spec.helm.main.location is declared as a bare str with no semantic validation, so a location that has no chart-name path segment (e.g. a bare (host/redacted) with no trailing path) is accepted at driver-load time and only produces an invalid Kubernetes object much later, at deploy time. **Affected files:** python_sdk/src/styrmin_sdk/driver_format/models/resources/driver.py:103-107 (HelmSettings.location: str has zero validation), python_sdk/src/styrmin_sdk/driver_format/context/naming.py:12-39 (get_chart_name_from_chart_url/get_chart_repository_from_chart_url blindly split on the last /), backend/styrmin_backend/services/applications.py:352-369` (calls both naming functions unconditionally when registering the driver version).

Replication test

Test file: python_sdk/tests/driver_format/test_check_errors.py
Test name: test_a_location_with_no_chart_name_is_an_error
What it tests: Running styrmin-driver check against a driver whose spec.helm.main.location is (registry.opsmill.io/redacted) (a scheme + host with no chart-name path segment, mirroring the issue's reproduction) should fail the load with a spec.helm.main.location` validation error — it currently passes silently instead.

Local run (evidence)

python_sdk/tests/driver_format/test_check_errors.py::test_a_location_with_no_chart_name_is_an_error FAILED

    def test_a_location_with_no_chart_name_is_an_error(example_copy, run_cli) -> None:
        driver = example_copy("simple-app")
        edit_spec(driver, lambda data: data["spec"]["helm"]["main"].update(location="(registry.opsmill.io/redacted)

        result = run_cli("check", str(driver))

>       assert (
            f"{driver}/driver.styrmin.yml:{_spec_line(driver, 'location:')}: error: spec.helm.main.location:" in result.out
        )
E       assert '.../driver.styrmin.yml:15: error: spec.helm.main.location:' in ".../driver.styrmin.yml:7: warning: no default_version; the example context uses application version '0.1'; set app.version in a context file to change it\n.../simple-app: 0 errors, 1 warning\n"
E        +  where "...warning...\n.../simple-app: 0 errors, 1 warning\n" = CliResult(code=0, out="...", err='styrmin-driver: warning: the template is rendered without a sandbox and can run code on this machine; use it only on drivers you trust\n').out

1 failed in 0.10s

Expected CI signal: the Python SDK Unit Tests check should FAIL on this PR, for this reason: check reports 0 errors, 1 warning and exits 0 for a driver whose helm.main.location has no chart name, instead of rejecting it at load time as the analyst's root cause requires.

Test expectations

Asserts that styrmin-driver check on a driver with spec.helm.main.location: (registry.opsmill.io/redacted) (scheme + host, no chart-name path segment — the same shape as the issue's (chartrepo.chartregistry.svc.cluster.local/redacted) reproduction) exits with code 1 and reports a spec.helm.main.location error anchored to the location: line of driver.styrmin.yml, following the same per-field error format the CLI already uses for other invalid fields (e.g. spec.info.license, spec.info.authors).

Edge cases called out by the analyst but intentionally left to the fixer/reviewer to add separate coverage for (not asserted by this test): a trailing-slash-only path (`(host/redacted) and the unsupported-scheme case.

AGENT_TEST_COMPLETE

Generated by Bug test-writer agent · claude · agent · ~84 AIC · ⌖ ~2 AIC · ⊞ 5.5K · ◷

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add opsmill/opsmill-cicd-workflows/workflows/bug-agent-test.md@chore/gh-aw-1.2.2

<!-- This is an auto-generated description by cubic. -->
<a href="(cubic.dev/redacted) target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="(www.cubic.dev/redacted)&lt;source media="(prefers-color-scheme: light)" srcset="(www.cubic.dev/redacted)&lt;img alt="View guided diff" src="(www.cubic.dev/redacted)&lt;/picture&gt;&lt;/a> <a href="(www.cubic.dev/redacted) target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="(www.cubic.dev/redacted)&lt;source media="(prefers-color-scheme: light)" srcset="(www.cubic.dev/redacted)&lt;img alt="Turn on auto-fix" src="(www.cubic.dev/redacted)&lt;/picture&gt;&lt;/a>

<!-- End of auto-generated description by cubic. -->


Fix strategy

Followed the analyst's strategy as written. Added a field_validator on HelmSettings.location (python_sdk/src/styrmin_sdk/driver_format/models/resources/driver.py) that hard-fails the load when:

  1. the value is not a well-formed absolute URL with scheme http, https, or oci, or
  2. the URL has no non-empty path segment after the host (i.e. no chart name) — including the host/ trailing-slash-only edge case the analyst flagged.

This is a hard ValueError (not a soft warning like Info.icon/InfoLink.url), per the analyst's reasoning: a chart with no resolvable location already fails deployment unconditionally, just late. naming.py and applications.py are unchanged, as recommended — they can now assume a well-formed <scheme>://<host>/.../<chart> because the model guarantees it.

_url_problem (built on HttpUrl) could not be reused because HttpUrl rejects the oci scheme that location must support, so I added a sibling helper (_chart_location_problem) built on AnyUrl, following the same "problem string or None" shape.

Unplanned but necessary scope: the shared driver/examples/simple-app and driver/examples/db-test fixtures (used by ~20 python_sdk/backend unit tests, plus e2e) themselves had location: simple-app / location: db-test — a bare name with no scheme and no chart name, i.e. an even more extreme instance of the bug this PR fixes. Once real validation exists, those fixtures fail to load. I updated both to a well-formed (redacted) location (e2e tests already rewrite location to a real chart-server URL before any deployment, via preparedriver in backend/tests/e2e/conftest.py, so this doesn't affect deployment behavior there). I made the equivalent fix to 2 e2e "broken driver" fixtures that are copied verbatim without that rewrite (backend/tests/e2e/fixtures/drivers/broken/{missing-action,retired-filter}/driver.styrmin.yml), and to 6 backend unit test files that inlined an equally invalid literal location ("./src/helm", "test-chart", "(example/redacted) as throwaway fixture data unrelated to what each test actually exercises. None of these are the replication test itself (python_sdk/tests/driver_format/test_check_errors.py is untouched — verified via git diff).

I also fixed a message-duplication bug I introduced during development: my validator's message originally repeated (found {value!r}), which doubled up with the generic Pydantic-error formatter's own (found ...) suffix (python_sdk/src/styrmin_sdk/driver_format/reading/deserializers.py::validation_error_fields). Removed the duplicate from my message.

Local run (evidence)

Replication test, before the fix (confirms it starts red):

FAILED python_sdk/tests/driver_format/test_check_errors.py::test_a_location_with_no_chart_name_is_an_error
assert '.../driver.styrmin.yml:15: error: spec.helm.main.location:' in "...: 0 errors, 1 warning\n"

After the fix:

$ uv run pytest python_sdk/tests/ -q
633 passed, 1 xfailed in 11.35s

$ uv run pytest backend/tests/unit/services/driver -q
370 passed in 2.47s

$ uv run pytest backend/tests/unit/services/driver/test_deserializer.py -q
18 passed in 0.08s

uv run invoke format lint passes clean (ruff, ty, GraphQL schema/codegen validation — no GraphQL surface changed in this PR).

Not run locally: backend/tests/unit as a whole includes Docker/testcontainers-backed tests (postgresql fixture) that require a Docker daemon unavailable in this sandbox (15 unrelated ConnectionRefusedError errors, pre-existing environment limitation, not caused by this change). One unrelated pre-existing failure also observed and left alone: backend/tests/unit/services/telemetry/test_sender.py::test_send_report_returns_false_when_the_host_name_does_not_resolve (DNS-mocking test, no relation to driver/helm code).

AGENT_FIX_COMPLETE

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • telemetry.invalid

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "telemetry.invalid"

See Network Configuration for more information.

Generated by Bug fixer agent · claude · agent · ~422 AIC · ⌖ ~2 AIC · ⊞ 5.3K · ◷

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add opsmill/opsmill-cicd-workflows/workflows/bug-agent-fix.md@chore/gh-aw-1.2.2

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Deploying styrmin with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab73980
Status: ✅  Deploy successful!
Preview URL: https://36ed92a1.styrmin.pages.dev
Branch Preview URL: https://ai-bug-pipeline-620-helm-loc.styrmin.pages.dev

View logs

@opsmill-bug-pipeline

Copy link
Copy Markdown
Contributor Author

AGENT_REVIEW_VERDICT: TEST_APPROVED

Verdict: TEST_APPROVED

CI signal

Python SDK Unit Tests is concluded failure — the expected signal for a test-only PR reproducing a bug. check currently reports 0 errors, 1 warning for a spec.helm.main.location with no chart-name segment; the new test correctly fails against that behavior.

Realism

(registry.opsmill.io/redacted) (scheme + host, no chart-name path segment) is a faithful reproduction of the issue's shape ((chartrepo.chartregistry.svc.cluster.local/redacted) and (redacted) is in fact the scheme used in HelmSettings's own documented example (driver.pymodule docstring:location: (registry.opsmill.io/redacted) — an even more central case for this field than copying the issue's `(redacted) literally.

Correctness

  • Asserts the expected (fixed) behavior: exit code 1 and a spec.helm.main.location: error anchored to the location: line (driver.styrmin.yml:15 for the simple-app fixture, matching the evidence log).
  • Exercises the analyst's affected path: HelmSettings.location validation at load time.
  • Cannot pass without the fix: today check exits 0 with only a warning, so this assertion requires real validation to be added.

Quality

  • Matches the existing test_every_invalid_field_is_reported_on_its_own_line / test_an_invalid_field_and_a_missing_action_function_are_reported_together convention exactly: {driver}/driver.styrmin.yml:{_spec_line(...)}: error: spec.X.Y: prefix, asserted as a substring (loose enough not to over-constrain the fixer's exact message).
  • Uses existing example_copy/edit_spec/_spec_line/run_cli fixtures/helpers already used throughout the file — isolated (copies the fixture driver) and deterministic.
  • _spec_line(driver, 'location:') is computed after edit_spec, but the matched text (location:) is the YAML key, which is unchanged by the edit (only the value changes), so the line number is stable.

Alignment

Directly targets the analyst's root cause (HelmSettings.location: str with no semantic validation) and leaves the trailing-slash-only and unsupported-scheme edge cases explicitly out of scope for the fixer/reviewer to extend — appropriately narrow for a single reproduction test.

No blocking issues found.

AGENT_REVIEW_ITERATION: test-1

Generated by Bug reviewer agent · agent · 63.9 AIC · ⊞ 8.6K · ◷

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add opsmill/opsmill-cicd-workflows/workflows/bug-agent-review.md@b376723a0cac214db01f3b8aa8e9750ac5dbe745

@opsmill-bug-pipeline opsmill-bug-pipeline Bot changed the title test: failing test for #620 — HelmSettings.location accepts a URL with no chart name fix: reject a Helm location with no chart name at load time (closes #620) Nov 27, 2026
… time (closes #620)

HelmSettings.location was a bare str with no validation, so a location
with no scheme or no chart-name path segment (e.g. a bare repository
root) was accepted at driver-load time and only produced an invalid
Kubernetes HelmRepository much later, at deploy time.

Add a field validator on HelmSettings.location that requires an
absolute http/https/oci URL with a non-empty chart-name path segment,
raising at load time instead. Fix fixture/test data across python_sdk
and backend unit tests that relied on the previously unvalidated
field (bare names like "simple-app" or "oci://example" with no path).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@opsmill-bug-pipeline

Copy link
Copy Markdown
Contributor Author

Commit pushed: ab73980

Generated by Bug fixer agent · claude · agent · ~422 AIC · ⌖ ~2 AIC · ⊞ 5.3K

@opsmill-bug-pipeline

Copy link
Copy Markdown
Contributor Author

AGENT_REVIEW_VERDICT: FIX_CHANGES_REQUESTED

Verdict: FIX_CHANGES_REQUESTED

CI signal

Python SDK Unit Tests is concluded success — the expected signal for a fix PR. The replication test (test_a_location_with_no_chart_name_is_an_error) now passes.

Correctness

Solves the analyst's root cause directly: HelmSettings.location now has a field_validator (python_sdk/src/styrmin_sdk/driver_format/models/resources/driver.py:113-119) that hard-rejects any value that isn't an absolute http/https/oci URL with a non-empty path segment after the host (_chart_location_problem, lines 108-118). Verified by hand:

  • `(registry.opsmill.io/redacted) (no chart name) → rejected ✓ (the replication test's exact input)
  • (host/redacted) (trailing-slash-only, the analyst's flagged edge case) → url.path == "/", .strip("/")` empties it → rejected ✓
  • a bare name with no scheme (simple-app) → AnyUrl validation fails → rejected ✓
  • `(registry.opsmill.io/redacted) → accepted ✓

naming.py and applications.py are confirmed untouched and both treat location strictly as a repo-URL + chart-name pair (applications.py:352-369), consistent with the new guarantee. The message-duplication fix is real: _chart_location_problem no longer appends (found ...) itself, avoiding the double suffix from validation_error_fields in deserializers.py.

The "unplanned but necessary scope" fixture rewrites check out: I traced every e2e fixture driver with a bare location (failing-actions, hook-job, late-container) through backend/tests/e2e/conftest.py::_prepare_driver, and all of them get their location rewritten to a real chart-server URL before being loaded anywhere, so they're unaffected. The two broken/* fixtures bypass that rewrite (copied verbatim at conftest.py:696-699), which is exactly why those two needed a direct edit to keep failing for their original reason instead of a new location error. The 6 backend unit test fixtures and driver/examples/* were the only remaining bad literals in the repo (confirmed by grep — nothing else left unaddressed).

Code quality

No unrelated refactor; the helper mirrors the existing _url_problem/_HTTP_URL pattern already used for InfoLink.url/Info.icon. No perf/security regressions.

Documentation alignment — blocking

docs/docs/drivers/creating-a-driver.md is now stale and actively contradicts this fix:

  • Line 190's example is location: my-app # OCI URL or local path the server can resolve — my-app is a bare string with no scheme, which validate_location now rejects at load time. A user copy-pasting this example gets a hard check failure.
  • Lines 203-206 document helm.main.location as accepting "an OCI URL ..., an HTTP repository URL, or a relative path in a chart directory of the server image." There is no code path that ever resolved a relative/local path (confirmed: applications.py always treats location as repo-URL + chart-name via naming.py), and this fix forecloses it explicitly by requiring an absolute http/https/oci URL. The "relative path" sentence needs to go, and the example needs a real chart name (e.g. `(registry.example.com/redacted)

This is exactly the case AGENTS.md calls non-negotiable: "Any update that touches user-visible behaviour (... driver format ...) MUST update the corresponding pages under docs/." The PR is the first place this scheme/chart-name requirement becomes enforced instead of aspirational, so it's the right place to fix the doc too.

Test integrity

The replication test (python_sdk/tests/driver_format/test_check_errors.py::test_a_location_with_no_chart_name_is_an_error) is unchanged by the fixer (confirmed via diff) and still asserts the expected post-fix behavior.

Action required: update docs/docs/drivers/creating-a-driver.md (the example at line 190 and the field description at lines 203-206) to match the new validation rule before this can be approved.

AGENT_REVIEW_ITERATION: fix-1

Generated by Bug reviewer agent · agent · 106.4 AIC · ⊞ 8.6K · ◷

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add opsmill/opsmill-cicd-workflows/workflows/bug-agent-review.md@b376723a0cac214db01f3b8aa8e9750ac5dbe745

@fatih-acar
fatih-acar marked this pull request as ready for review November 30, 2026 08:07
@fatih-acar
fatih-acar merged commit 23a57a4 into develop Nov 30, 2026
24 checks passed
@fatih-acar
fatih-acar deleted the ai-bug-pipeline-620-helm-location-no-chart-name-5e96ebcddc3d8bbd branch November 30, 2026 08:07
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