Conversation
…s an independent copy - this means that changes to unique key would no longer cause collisions
WalkthroughThe changes add defensive copying to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
drivers/pg/query/format.go (1)
216-216: Consider clarifying the self-referentialAddKindscall.This pattern—calling
batchNode.AddKinds(batchNode.Kinds...)—is semantically unusual: it re-adds existing kinds to populateAddedKinds. The intent (snapshotting kinds into the delta-tracking fields) isn't immediately obvious. A brief inline comment would help future readers.batchNode := graph.NewNode(update.Node.ID, update.Node.Properties.Clone(), update.Node.Kinds...) +// Snapshot existing kinds into AddedKinds so they're tracked for the batch operation. batchNode.AddKinds(batchNode.Kinds...)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@drivers/pg/query/format.go` at line 216, The call batchNode.AddKinds(batchNode.Kinds...) is re-appending the node's existing Kind list to populate its delta/added-tracking fields and should be clarified; add a concise inline comment next to the call (near the invocation of AddKinds in format.go) stating that this self-referential call is intentional and used to snapshot/copy the current batchNode.Kinds into the node's AddedKinds (or delta-tracking) so readers understand it isn’t a bug but a deliberate population step.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@drivers/pg/query/format.go`:
- Line 216: The call batchNode.AddKinds(batchNode.Kinds...) is re-appending the
node's existing Kind list to populate its delta/added-tracking fields and should
be clarified; add a concise inline comment next to the call (near the invocation
of AddKinds in format.go) stating that this self-referential call is intentional
and used to snapshot/copy the current batchNode.Kinds into the node's AddedKinds
(or delta-tracking) so readers understand it isn’t a bug but a deliberate
population step.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b51d05f-d0c0-4261-9ac9-e36905c45bab
📒 Files selected for processing (2)
drivers/pg/query/format.godrivers/pg/query/format_test.go
|
Had a discussion with Katherine on this PR. If keys for the batch upsert are being modified after being added to the batch IMO that's the underlying issue that should be addressed. Right now, unfortunately we cannot locally reproduce the issue and don't have enough information. At this point I think the best course of action is to improve error logging and figure out if we can extract the conflicting objectid from the db error so that we can better understand what is happening. |
Bloodhound is experiencing errors during ingest as such:
{"time":"2026-02-20T00:36:36.016146471Z","level":"ERROR","message":"Error reading ingest file /opt/bhe/work/tmp/bhe641820275: ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time (SQLSTATE 21000)"}More error logs / details can be found in the ticket: https://specterops.atlassian.net/browse/BED-7483
Steps I took to come up with this cause/fix
What I believe to be the root cause of the error:
Proposed fix
I would appreciate feedback on this fix. Being that it's flaky, it's pretty difficult to reproduce. I am torn on returning
rows.Err()because I'm not sure if these errors are being swallowed for a specific reason.Summary by CodeRabbit
Release Notes
Bug Fixes
Tests