Skip to content

(PA-7812) Only check_schema on resources actually consumed - #387

Merged
david22swan merged 1 commit into
mainfrom
PA-7812
Jun 17, 2026
Merged

(PA-7812) Only check_schema on resources actually consumed#387
david22swan merged 1 commit into
mainfrom
PA-7812

Conversation

@tvpartytonight

Copy link
Copy Markdown
Contributor

Problem

In v2.0.0 the Resource API introduced caching of provider get() results. As part of that change, type_definition.check_schema was moved into the cache-population loop in rsapi_provider_get. Combined with the get() optimization (PR #306), a single get(context) call now fetches all resources of a type and caches them — so check_schema runs against every resource on the system during an apply, including resources the catalog does not manage.

The result: modules that previously ran fine now error out because an unrelated, unmanaged resource returned by get() happens to violate the type schema.

Fix

Restore the pre-2.0.0 semantics — only schema-check the resources that are actually consumed:

  • rsapi_provider_get only populates the cache (no longer checks schema).
  • instances checks each resource (this path backs puppet resource, which is meant to validate everything it lists).
  • refresh_current_state checks only the single matched resource (the one being managed).

SimpleProvider already performs its own check_schema independently, so it is unaffected.

Testing

  • Full unit suite (bundle exec rake spec:unit): 1447 examples, 0 failures.
  • Added a regression test: a provider returns the managed resource (valid) alongside an unmanaged resource with schema violations; under strict: :error, retrieving the managed resource no longer raises. Confirmed this test fails without the fix and passes with it.
  • Rubocop clean on changed files.

🤖 Generated with Claude Code

The v2.0.0 caching change moved check_schema into the cache-population
loop in rsapi_provider_get. Combined with the get() optimization (a
single get(context) fetches all resources of a type), this caused every
resource on the system to be schema-checked during an apply, including
resources not managed by the catalog. Modules that previously ran fine
would then error on unrelated resources with schema violations.

Restore the pre-2.0.0 semantics: only schema-check the resources that
are actually consumed.
- rsapi_provider_get only populates the cache
- instances checks each resource (backs `puppet resource`)
- refresh_current_state checks only the single matched resource

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tvpartytonight
tvpartytonight requested review from a team as code owners June 15, 2026 22:18
@david22swan
david22swan merged commit 1d721fd into main Jun 17, 2026
6 of 7 checks passed
@david22swan
david22swan deleted the PA-7812 branch June 17, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants