Skip to content

fix(nullplatform): fail template fetches that do not return 200 - #482

Merged
jcastiarena merged 4 commits into
mainfrom
fix/template-fetch-status-check
Aug 7, 2026
Merged

fix(nullplatform): fail template fetches that do not return 200#482
jcastiarena merged 4 commits into
mainfrom
fix/template-fetch-status-check

Conversation

@jcastiarena

Copy link
Copy Markdown
Contributor

What

Every template fetch in scope_definition, service_definition,
scope_definition_agent_association and parameter_storage_definition now
asserts status_code == 200 through a postcondition.

Why

A non-2xx response is not an error for the http provider, so a renamed or
missing template flowed on as if the response body were the template:
gomplate passed it through and jq died with

jq: parse error: Expected string key before ':' at line 1, column 4

four layers away from the file that caused it — that : is the one in
404: Not Found. The try(..., "{}") wrapped around response_body does not
help, because there was no error to catch.

Not hypothetical: nullplatform/scopes renamed kill-instances.json.tpl to
kill-instance.json.tpl, and since the branch defaults track a moving ref
(refs/heads/main), that broke the plan of an already-applied state with no
change in the caller's configuration.

After

Error: Resource postcondition failed

  with module.sd.data.http.action_templates["kill-instances"],
    │ self.status_code is 404

Fetch of https://raw.githubusercontent.com/nullplatform/scopes/refs/heads/main/k8s/specs/actions/kill-instances.json.tpl
returned HTTP 404, expected 200. Check that the action name is spelled as the
template file in the scope repository.

Verification

  • Reproduced the 404 against the real repository: the postcondition fires and
    the message names the URL.
  • Happy path unchanged: Plan: 5 to add, 0 to change, 0 to destroy, no
    postcondition triggered.
  • pre-commit run --files on the four changed files: tofu-fmt,
    tofu-validate, tofu test, trailing-whitespace, detect-private-key all
    pass; commitlint passes on the commit.
  • pre-commit run --all-files exits 1 on main before this branch:
    infrastructure/aws/vpc/main.tf and nullplatform/asset/ecr/main.tf are
    unformatted, and infrastructure/gcp/gke cannot resolve hashicorp/google
    under -lockfile=readonly. Confirmed on a pristine origin/main worktree, so
    it is not caused by this change. The four modules touched here validate clean
    in that same run (73 validated, 72 valid, the one failure being gcp/gke).

Not included

No test pins this behaviour: none of the four modules has a tests/ suite, and
adding one needs mock_provider "http" returning a chosen status_code plus a
mocked body that the downstream data.external (gomplate/jq) can survive. Worth
a follow-up rather than stretching this change.

A non-2xx response is not an error for the http provider, so a renamed or
missing template flowed on as if the response body were the template: gomplate
passed it through and jq died with `parse error: Expected string key before
':'`, four layers away from the file that caused it. Since the branch defaults
track a moving ref, an upstream rename can break an already-applied state with
no change in the caller's configuration.

Assert `status_code == 200` on every template fetch in scope_definition,
service_definition, scope_definition_agent_association and
parameter_storage_definition, so the failure names the URL instead.
…ables

The tflint-unused-declarations job lints every changed module, so this PR
surfaced debt it did not introduce: np_api_key in parameter_storage_definition
and github_repo_url/github_ref in scope_definition_agent_association are
declared and unused on main too.

None of the three can be deleted, which is what tflint marks as [Fixable]:

- np_api_key is published and passed by consumers for interface consistency
  across the parameter-storage modules. The provider is configured at the root,
  which is why nothing inside the module references it.
- github_repo_url and github_ref are published inputs with defaults, superseded
  by repository_notification_channel/_branch, which is what the template fetch
  actually uses. Dropping either breaks any consumer that sets it.

Annotate all three with the rationale inline. Removing them belongs in a major
version bump with coordinated consumer updates, not here.
Same content in half the lines: the why stays, the retelling of the failure
chain goes. No functional change — comments only.
@timossileandro
timossileandro self-requested a review August 7, 2026 18:36

@timossileandro timossileandro 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.

ok

…atus-check

# Conflicts:
#	nullplatform/scope_definition_agent_association/variables.tf
@jcastiarena
jcastiarena merged commit c47b78b into main Aug 7, 2026
45 checks passed
@jcastiarena
jcastiarena deleted the fix/template-fetch-status-check branch August 7, 2026 18:46
sebastiancorrea81 added a commit that referenced this pull request Aug 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[6.11.0](v6.10.0...v6.11.0)
(2026-08-07)


### Features

* **agent:** worker orchestration passthrough + chart 2.37.0
([#478](#478))
([6758a95](6758a95))
* **service_definition:** allow pinning specs to a tag or commit SHA
([#470](#470))
([15b6d47](15b6d47))


### Bug Fixes

* **azure/vnet:** let a subnet declare its route table
([#475](#475))
([d2a5faf](d2a5faf))
* **docs:** update usage example to a current release tag
([a167934](a167934))
* **docs:** update usage example to a current release tag
([#484](#484))
([ed6f5b0](ed6f5b0))
* **nullplatform:** fail template fetches that do not return 200
([#482](#482))
([c47b78b](c47b78b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants