Skip to content

fix: resolve enable_introspection env variable at runtime (#1211) - #1247

Open
ousamabenyounes wants to merge 1 commit into
overblog:masterfrom
ousamabenyounes:fix/issue-1211
Open

fix: resolve enable_introspection env variable at runtime (#1211)#1247
ousamabenyounes wants to merge 1 commit into
overblog:masterfrom
ousamabenyounes:fix/issue-1211

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Documented? no
Fixed tickets #1211
License MIT

Problem

security.enable_introspection was evaluated at container-compile time:

if ($config['security']['enable_introspection']) {
    $executorDefinition->addMethodCall('enableIntrospectionQuery');
} else {
    $executorDefinition->addMethodCall('disableIntrospectionQuery');
}

When the option is backed by an environment variable:

overblog_graphql:
    security:
        enable_introspection: '%env(bool:GRAPHQL_ENABLE_INTROSPECTION)%'

at compile time $config['security']['enable_introspection'] is still an unresolved
placeholder string (e.g. env_..._GRAPHQL_ENABLE_INTROSPECTION_...), which is always
truthy — so introspection stays enabled regardless of the variable.

Fix

Pass the parameter reference to a new Executor::setIntrospectionQueryEnabled(bool)
method call. The value — including the env variable — is then resolved when the service
is instantiated at runtime, not at compile time. The existing
enableIntrospectionQuery() / disableIntrospectionQuery() methods are kept and now
delegate to it, so there is no BC break.

Test verification (RED → GREEN)

New functional test boots a kernel whose enable_introspection is bound to an env
variable, sets it to false, and asserts introspection is blocked.

RED — on the unmodified branch (fix reverted, test only), the env variable is
ignored and introspection stays enabled:

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

GREEN — with the fix, both the env-disabled and env-enabled cases pass:

OK (2 tests, 3 assertions)

Full suite is iso-baseline (the 5 pre-existing GraphDumpSchemaCommandTest failures on
master are unrelated to this change and stay unchanged): Tests: 713, Failures: 5.

The security.enable_introspection option was evaluated at container-compile
time. When it was backed by an environment variable, the value was still an
unresolved placeholder string (always truthy), so introspection stayed enabled
regardless of the variable.

Pass the parameter reference to a new Executor::setIntrospectionQueryEnabled()
method call so the value — including an env variable — is resolved when the
service is instantiated. The existing enable/disableIntrospectionQuery() methods
are kept and now delegate to it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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