Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

sqlserver::user::permissions always applied as corrective

Đang mở Phù hợp với người mới
#509 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

@davidassigbi đang làm issue này rồi.

Từ ngày 29/7/2026.

  • #508 của @davidassigbi — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
92/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
sql
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu với templates/query/user/permission_exists.sql.epp và so sánh nó với templates/create/user/permission.sql.epp và templates/query/role/permission_exists.sql.epp. Kiểm tra thiết lập của biến permission, sau đó chạy bản tái hiện Puppet đã nêu hai lần. Hoàn tất khi lần chạy thứ hai báo cáo rằng tài nguyên sqlserver_tsql đã đồng bộ mà không áp dụng lại các quyền GRANT.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bugfix community

Describe the Bug

When declaring sqlserver::user::permissions with GRANT permissions, Puppet re-applies the permissions on every run as a corrective change, even though the permissions are already in the desired state.

Expected Behavior

On the second Puppet run (after permissions are already granted), the sqlserver_tsql resource should be in sync and no corrective change should occur.

Steps to Reproduce

  1. Declare sqlserver::user::permissions with e.g. permissions: ['SELECT', 'INSERT'] and state: GRANT
  2. Run Puppet agent — permissions are applied
  3. Run Puppet agent again — permissions are re-applied as corrective

Root Cause

The onlyif query template templates/query/user/permission_exists.sql.epp iterates over permissions but never assigns the SQL variable @permission:

<% $permissions.each |$requested_permission| { %>
    <% $permission = $requested_permission.upcase %>
<%= epp('sqlserver/snippets/user/permission/exists.sql.epp', ...) %>
<% } %>

The Puppet variable $permission is set, but the SQL variable @permission stays NULL. Since permission_name = NULL is never TRUE in SQL Server, the subquery always returns NULL, ISNULL coerces it to 'REVOKE', and the check always sees a mismatch — causing Puppet to re-grant every time.

The create template (templates/create/user/permission.sql.epp) and the role equivalent (templates/query/role/permission_exists.sql.epp) both correctly set @permission. This is the same class of bug as #464 / #500 which fixed the login permission template.

Fix

Add the missing SET @permission = '<%= $permission %>'; line in the query template, matching the create template.

Ngôn ngữ chính
Ruby
Star
5
Fork
23
Merge trung bình
3 giờ 17 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của puppetlabs/puppetlabs-sqlserver

Tất cả issue của puppetlabs/puppetlabs-sqlserver

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.