Skip to content

fix: only insert those configs that exist#1876

Open
yashmehrotra wants to merge 1 commit intomainfrom
insert-only-if-notif-send
Open

fix: only insert those configs that exist#1876
yashmehrotra wants to merge 1 commit intomainfrom
insert-only-if-notif-send

Conversation

@yashmehrotra
Copy link
Copy Markdown
Member

@yashmehrotra yashmehrotra commented Apr 10, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where configuration change records could be created for deleted or inactive configuration items. The system now validates that configuration items exist and are active before recording changes.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 10, 2026

Benchstat (Other)

Base: 7262acc74e43ab6bda74cd4f9fdb3f23f6888fd9
Head: d8a360e36f10b785b7db1c73d14c5ede92c794b9

✅ 2 improvement(s)
Benchmark Base Head Change p-value
ResourceSelectorQueryBuild/tags-4 17.58µ 17.02µ -3.17% 0.002
ResourceSelectorQueryBuild/name-4 44.16µ 43.28µ -1.99% 0.015
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                                       │ bench-base.txt │           bench-head.txt           │
                                                       │     sec/op     │    sec/op     vs base              │
InsertionForRowsWithAliases/external_users.aliases-4       592.4µ ±  5%   599.5µ ±  4%       ~ (p=0.310 n=6)
InsertionForRowsWithAliases/config_items.external_id-4     1.106m ± 10%   1.116m ± 10%       ~ (p=0.818 n=6)
ResourceSelectorConfigs/name-4                             208.6µ ±  5%   207.2µ ±  2%       ~ (p=0.394 n=6)
ResourceSelectorConfigs/name_and_type-4                    229.1µ ±  3%   224.8µ ±  4%       ~ (p=0.394 n=6)
ResourceSelectorConfigs/tags-4                             29.63m ±  3%   29.58m ±  4%       ~ (p=1.000 n=6)
ResourceSelectorQueryBuild/name-4                          44.16µ ±  1%   43.28µ ±  2%  -1.99% (p=0.015 n=6)
ResourceSelectorQueryBuild/name_and_type-4                 64.29µ ±  1%   63.46µ ±  2%       ~ (p=0.065 n=6)
ResourceSelectorQueryBuild/tags-4                          17.58µ ±  1%   17.02µ ±  1%  -3.17% (p=0.002 n=6)
geomean                                                    287.2µ         284.6µ        -0.90%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 10, 2026

Benchstat (RLS)

Base: 7262acc74e43ab6bda74cd4f9fdb3f23f6888fd9
Head: d8a360e36f10b785b7db1c73d14c5ede92c794b9

📊 5 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
RLS/Sample-15000/config_names/Without_RLS-4 11.71m 12.01m +2.56% 0.002
RLS/Sample-15000/configs/Without_RLS-4 6.325m 6.402m +1.23% 0.026
RLS/Sample-15000/catalog_changes/Without_RLS-4 4.374m 4.410m +0.81% 0.002
RLS/Sample-15000/config_names/With_RLS-4 109.1m 109.5m +0.43% 0.015
RLS/Sample-15000/config_changes/With_RLS-4 112.2m 112.5m +0.31% 0.041
✅ 3 improvement(s)
Benchmark Base Head Change p-value
RLS/Sample-15000/change_types/With_RLS-4 4.546m 4.423m -2.70% 0.002
RLS/Sample-15000/analysis_types/With_RLS-4 3.388m 3.361m -0.77% 0.041
RLS/Sample-15000/configs/With_RLS-4 108.2m 107.8m -0.34% 0.015
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 9V74 80-Core Processor                
                                               │ bench-base.txt │          bench-head.txt           │
                                               │     sec/op     │   sec/op     vs base              │
RLS/Sample-15000/catalog_changes/Without_RLS-4      4.374m ± 1%   4.410m ± 2%  +0.81% (p=0.002 n=6)
RLS/Sample-15000/catalog_changes/With_RLS-4         112.5m ± 1%   113.3m ± 0%       ~ (p=0.065 n=6)
RLS/Sample-15000/config_changes/Without_RLS-4       4.367m ± 1%   4.414m ± 3%       ~ (p=0.132 n=6)
RLS/Sample-15000/config_changes/With_RLS-4          112.2m ± 0%   112.5m ± 1%  +0.31% (p=0.041 n=6)
RLS/Sample-15000/config_detail/Without_RLS-4        3.417m ± 3%   3.400m ± 2%       ~ (p=0.937 n=6)
RLS/Sample-15000/config_detail/With_RLS-4           108.5m ± 0%   108.9m ± 1%       ~ (p=0.065 n=6)
RLS/Sample-15000/config_names/Without_RLS-4         11.71m ± 1%   12.01m ± 0%  +2.56% (p=0.002 n=6)
RLS/Sample-15000/config_names/With_RLS-4            109.1m ± 0%   109.5m ± 1%  +0.43% (p=0.015 n=6)
RLS/Sample-15000/config_summary/Without_RLS-4       52.62m ± 3%   52.61m ± 1%       ~ (p=0.937 n=6)
RLS/Sample-15000/config_summary/With_RLS-4          641.5m ± 1%   635.0m ± 2%       ~ (p=0.093 n=6)
RLS/Sample-15000/configs/Without_RLS-4              6.325m ± 2%   6.402m ± 4%  +1.23% (p=0.026 n=6)
RLS/Sample-15000/configs/With_RLS-4                 108.2m ± 2%   107.8m ± 0%  -0.34% (p=0.015 n=6)
RLS/Sample-15000/analysis_types/Without_RLS-4       3.371m ± 1%   3.353m ± 2%       ~ (p=0.310 n=6)
RLS/Sample-15000/analysis_types/With_RLS-4          3.388m ± 3%   3.361m ± 2%  -0.77% (p=0.041 n=6)
RLS/Sample-15000/analyzer_types/Without_RLS-4       3.190m ± 2%   3.222m ± 1%       ~ (p=0.132 n=6)
RLS/Sample-15000/analyzer_types/With_RLS-4          3.251m ± 5%   3.219m ± 3%       ~ (p=0.132 n=6)
RLS/Sample-15000/change_types/Without_RLS-4         4.412m ± 2%   4.376m ± 1%       ~ (p=0.065 n=6)
RLS/Sample-15000/change_types/With_RLS-4            4.546m ± 1%   4.423m ± 2%  -2.70% (p=0.002 n=6)
RLS/Sample-15000/config_classes/Without_RLS-4       2.805m ± 2%   2.794m ± 3%       ~ (p=0.180 n=6)
RLS/Sample-15000/config_classes/With_RLS-4          108.1m ± 1%   108.8m ± 1%       ~ (p=0.132 n=6)
RLS/Sample-15000/config_types/Without_RLS-4         3.390m ± 1%   3.395m ± 2%       ~ (p=0.394 n=6)
RLS/Sample-15000/config_types/With_RLS-4            108.6m ± 1%   108.4m ± 2%       ~ (p=0.485 n=6)
geomean                                             16.60m        16.61m       +0.04%

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1807ffff-a2a4-4e3f-b4a0-0bef4014bd4d

📥 Commits

Reviewing files that changed from the base of the PR and between 7262acc and d8a360e.

📒 Files selected for processing (1)
  • views/021_notification.sql

Walkthrough

Modifies the insert_notification_history_config_change() trigger in the notification view to conditionally insert rows into config_changes only when the referenced config_items row exists and is not deleted, adding a validation check that was previously missing.

Changes

Cohort / File(s) Summary
Notification trigger enhancement
views/021_notification.sql
Added condition to verify referenced config_items row exists and is active (deleted_at IS NULL) before inserting into config_changes table in the notification history config change trigger.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: only insert those configs that exist' directly and specifically summarizes the main change in the pull request—making insertion into config_changes conditional on the referenced config_items row existing and being active.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch insert-only-if-notif-send
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch insert-only-if-notif-send

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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