Skip to content

Set permission variable in user permission_exists SQL EPP - #508

Open
davidassigbi wants to merge 1 commit into
puppetlabs:mainfrom
davidassigbi:fix/user-permission-onlyif-null-var
Open

Set permission variable in user permission_exists SQL EPP#508
davidassigbi wants to merge 1 commit into
puppetlabs:mainfrom
davidassigbi:fix/user-permission-onlyif-null-var

Conversation

@davidassigbi

@davidassigbi davidassigbi commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #509

The permission variable is not set in the template file templates/query/user/permission_exists.sql.epp. This creates a faulty tsql query when checking if the user permission already exists. The @permission SQL variable stays NULL, so the subquery WHERE permission_name = @permission never matches, ISNULL always returns 'REVOKE', and the onlyif check always fails — causing Puppet to re-apply permissions as corrective on every run.

This commit sets the @permission variable to fix this issue. Same class of bug as #500 which fixed templates/create/login/permission.sql.epp.

@davidassigbi
davidassigbi requested a review from a team as a code owner July 29, 2026 12:59
…spurious corrective runs

The permission_exists.sql.epp template never assigned the SQL variable
@Permission inside its loop, so it stayed NULL. Since permission_name =
NULL is never TRUE, the onlyif subquery always returned NULL, ISNULL
coerced it to 'REVOKE', and the check always saw a mismatch — causing
Puppet to re-grant permissions on every run.
@jst-cyr

jst-cyr commented Aug 21, 2026

Copy link
Copy Markdown
Member

Running CI for this PR here: #510

@jst-cyr

jst-cyr commented Aug 22, 2026

Copy link
Copy Markdown
Member

**Acceptance Test Results: ** https://github.com/puppetlabs/puppetlabs-sqlserver/actions/runs/32536992100

All green on acceptance. Next step is an engineering review when the team is available.

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.

sqlserver::user::permissions always applied as corrective

2 participants