(PA-7812) Only check_schema on resources actually consumed - #387
Merged
Conversation
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>
david22swan
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In v2.0.0 the Resource API introduced caching of provider
get()results. As part of that change,type_definition.check_schemawas moved into the cache-population loop inrsapi_provider_get. Combined with theget()optimization (PR #306), a singleget(context)call now fetches all resources of a type and caches them — socheck_schemaruns 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_getonly populates the cache (no longer checks schema).instanceschecks each resource (this path backspuppet resource, which is meant to validate everything it lists).refresh_current_statechecks only the single matched resource (the one being managed).SimpleProvideralready performs its owncheck_schemaindependently, so it is unaffected.Testing
bundle exec rake spec:unit): 1447 examples, 0 failures.strict: :error, retrieving the managed resource no longer raises. Confirmed this test fails without the fix and passes with it.🤖 Generated with Claude Code