Skip to content

fix: Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of :global_scope#350

Open
griggi-ws wants to merge 2 commits intoOpenVoxProject:mainfrom
griggi-ws:deferred_puppetlang
Open

fix: Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of :global_scope#350
griggi-ws wants to merge 2 commits intoOpenVoxProject:mainfrom
griggi-ws:deferred_puppetlang

Conversation

@griggi-ws
Copy link

@griggi-ws griggi-ws commented Feb 25, 2026

Hey folks, found an issue with Deferred resolution of Puppet-language functions while testing a control-repo with Onceover that makes heavy use of some custom functions that are mocked in Onceover's config, and did some digging.

The error was:

NoMethodError:
       undefined method `with_global_scope' for {}:Hash

Puppet-language functions use the Named Closure, which explicitly looks up :global_scope and returns an empty Hash as a fallback.

The DeferredResolver creates a new compiler instance which includes :global_scope in its context_overrides, but the resolver's call to resolve_futures does not use them.

This means when a Puppet-lang Deferred function is resolved, enclosing_scope is {}, and when the Closure's invoke is called (expecting a Scope object with the method with_global_scope), it errors out since we have an empty Hash instead of a Scope.

By wrapping the resolve_futures call in a compiler.with_context_overrides block, :global_scope is a valid instance of Scope, and the function can be resolved.

I added a spec test for Deferred processing of Puppet-lang functions, validated the failure, and applied the fix.

@griggi-ws griggi-ws changed the title fix: Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of global_context fix: Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of :global_scope Feb 25, 2026
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