Skip to content

Conversation

@LawsonWillard
Copy link
Contributor

@LawsonWillard LawsonWillard commented Nov 25, 2025

Description

Added a new schema_edge_kinds table and the create and read by id methods used to interact with it.
Added integration tests to cover these methods.

Motivation and Context

Resolves: BED-6790

This feature is required to enable OpenGraph schemas

How Has This Been Tested?

  • Added integration tests for DB methods.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Database Migrations

Checklist:

Summary by CodeRabbit

  • New Features
    • Added schema edge kind management: create and retrieve edge kinds for graph schema extensions (name, description, traversability).
    • Database migration adds backing table and index for edge kinds.
  • Bug Fixes
    • Explicit error handling for duplicate edge kind names.
  • Tests
    • Integration tests covering create, retrieve, duplicate-name and not-found scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@LawsonWillard LawsonWillard self-assigned this Nov 25, 2025
@LawsonWillard LawsonWillard added enhancement New feature or request api A pull request containing changes affecting the API code. labels Nov 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Walkthrough

Adds a new SchemaEdgeKind model and DB table plus migration, implements create/get DB methods (with duplicate-name error mapping), updates gomock mocks, and adds integration tests covering creation, retrieval, not-found, and duplicate-name handling.

Changes

Cohort / File(s) Change Summary
Error Definitions
cmd/api/src/database/db.go
Added public error variable ErrDuplicateSchemaEdgeKindName = errors.New("duplicate schema edge kind name").
Database Methods
cmd/api/src/database/graphschema.go
Added interface methods and BloodhoundDB implementations: CreateSchemaEdgeKind(ctx, name, schemaExtensionId, description, isTraversable) (INSERT ... RETURNING; maps unique-constraint violation to ErrDuplicateSchemaEdgeKindName) and GetSchemaEdgeKindById(ctx, id) (SELECT by id).
Model Definition
cmd/api/src/model/graphschema.go
New SchemaEdgeKind type with fields Serial, SchemaExtensionId, Name, Description, IsTraversable and TableName() returning "schema_edge_kinds".
Database Schema / Migration
cmd/api/src/database/migration/migrations/v8.5.0.sql
Added schema_edge_kinds table (id PK, schema_extension_id FK → schema_extensions(id) ON DELETE CASCADE, unique name, description, is_traversable, timestamps) and index idx_schema_edge_kinds_extensions_id.
Integration Tests
cmd/api/src/database/graphschema_test.go
Added TestDatabase_CreateAndGetSchemaEdgeKinds: creates extension, inserts two edge kinds, retrieves by ID, asserts fields, checks not-found behavior, and verifies duplicate-name error mapping.
Mocks
cmd/api/src/database/mocks/db.go
Added gomock support for CreateSchemaEdgeKind(...) and GetSchemaEdgeKindById(...) on MockDatabase and recorder methods.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as Caller
  participant DB as BloodhoundDB
  participant PG as Postgres

  rect rgb(220,240,255)
    Note over Caller,DB: CreateSchemaEdgeKind
    Caller->>DB: CreateSchemaEdgeKind(ctx, name, extId, desc, isTraversable)
    DB->>PG: INSERT INTO schema_edge_kinds (...) RETURNING *
    alt success
      PG-->>DB: inserted row
      DB-->>Caller: model.SchemaEdgeKind (created)
    else unique violation
      PG-->>DB: unique constraint error
      DB-->>Caller: ErrDuplicateSchemaEdgeKindName
    end
  end

  rect rgb(240,255,220)
    Note over Caller,DB: GetSchemaEdgeKindById
    Caller->>DB: GetSchemaEdgeKindById(ctx, id)
    DB->>PG: SELECT ... FROM schema_edge_kinds WHERE id = $1
    alt found
      PG-->>DB: row
      DB-->>Caller: model.SchemaEdgeKind
    else not found
      PG-->>DB: no rows
      DB-->>Caller: ErrEntityNotFound (via CheckError)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify migration FK, unique constraint, and index definitions in v8.5.0.sql.
  • Confirm SQL error-to-Go error mapping uses the correct DB constraint name and is tested.
  • Review tests for proper setup/teardown and coverage of success, duplicate, and not-found cases.

Suggested reviewers

  • wes-mil
  • AD7ZJ
  • superlinkx

Poem

🐇 I hopped to the DB with a nibble and grin,
Planted an edge kind where new paths begin.
Names lined in rows, neat and bright,
I bounced duplicates out with gentle might.
Hop, code, commit — the graph takes flight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding create/read functionality for schema edge kind database entries, with a Jira ticket reference.
Description check ✅ Passed The description covers the main changes, motivation, testing approach, and includes completed checklist items; however, testing details are minimal (only stating 'Added integration tests').
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BED-6790

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 225fb58 and f703afe.

📒 Files selected for processing (6)
  • cmd/api/src/database/db.go (1 hunks)
  • cmd/api/src/database/graphschema.go (2 hunks)
  • cmd/api/src/database/graphschema_test.go (1 hunks)
  • cmd/api/src/database/migration/migrations/v8.5.0.sql (1 hunks)
  • cmd/api/src/database/mocks/db.go (2 hunks)
  • cmd/api/src/model/graphschema.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/api/src/database/db.go
  • cmd/api/src/model/graphschema.go
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: LawsonWillard
Repo: SpecterOps/BloodHound PR: 2107
File: cmd/api/src/database/graphschema.go:86-100
Timestamp: 2025-11-25T22:11:53.518Z
Learning: In cmd/api/src/database/graphschema.go, the CreateSchemaEdgeKind method intentionally does not use AuditableTransaction or audit logging because it would create too much noise in the audit log, unlike CreateGraphSchemaExtension which does use auditing.
📚 Learning: 2025-11-25T22:11:53.518Z
Learnt from: LawsonWillard
Repo: SpecterOps/BloodHound PR: 2107
File: cmd/api/src/database/graphschema.go:86-100
Timestamp: 2025-11-25T22:11:53.518Z
Learning: In cmd/api/src/database/graphschema.go, the CreateSchemaEdgeKind method intentionally does not use AuditableTransaction or audit logging because it would create too much noise in the audit log, unlike CreateGraphSchemaExtension which does use auditing.

Applied to files:

  • cmd/api/src/database/graphschema.go
  • cmd/api/src/database/mocks/db.go
  • cmd/api/src/database/graphschema_test.go
  • cmd/api/src/database/migration/migrations/v8.5.0.sql
📚 Learning: 2025-06-06T23:12:14.181Z
Learnt from: elikmiller
Repo: SpecterOps/BloodHound PR: 1563
File: packages/go/graphschema/azure/azure.go:24-24
Timestamp: 2025-06-06T23:12:14.181Z
Learning: In BloodHound, files in packages/go/graphschema/*/`*.go` are generated from CUE schemas. When `just prepare-for-codereview` is run, it triggers code generation that may automatically add import aliases or other formatting changes. These changes are legitimate outputs of the generation process, not manual edits that would be overwritten.

Applied to files:

  • cmd/api/src/database/graphschema.go
🧬 Code graph analysis (2)
cmd/api/src/database/graphschema.go (3)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (75-82)
  • SchemaEdgeKind (84-86)
cmd/api/src/database/db.go (2)
  • BloodhoundDB (191-194)
  • ErrDuplicateSchemaEdgeKindName (58-58)
cmd/api/src/database/helper.go (1)
  • CheckError (26-32)
cmd/api/src/database/mocks/db.go (1)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (75-82)
  • SchemaEdgeKind (84-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build BloodHound Container Image / Build and Package Container
  • GitHub Check: run-analysis
  • GitHub Check: run-tests
  • GitHub Check: build-ui
🔇 Additional comments (6)
cmd/api/src/database/graphschema_test.go (1)

239-304: LGTM!

The integration test provides comprehensive coverage for SchemaEdgeKind operations:

  • Creates edge kinds with distinct traversability flags
  • Validates successful creation and retrieval
  • Verifies error handling for non-existent IDs
  • Confirms duplicate name detection

The helper function compareSchemaEdgeKind appropriately validates all fields without checking IDs (which are non-deterministic in parallel tests).

cmd/api/src/database/migration/migrations/v8.5.0.sql (1)

87-101: LGTM!

The schema_edge_kinds table definition is well-structured:

  • Appropriate foreign key with cascade delete
  • Unique constraint on name aligns with DAWGS requirements
  • Index on schema_extension_id for query performance
  • Consistent timestamp pattern with other schema tables
cmd/api/src/database/graphschema.go (3)

37-38: LGTM!

The interface method signatures are consistent with existing patterns and clearly define the contract for edge kind operations.


151-166: LGTM!

The implementation correctly:

  • Uses raw SQL with RETURNING to populate the model
  • Maps duplicate key constraints to ErrDuplicateSchemaEdgeKindName
  • Applies CheckError for general error handling
  • Follows the established pattern from CreateSchemaNodeKind

Based on learnings, the absence of AuditableTransaction is intentional to avoid audit log noise.


168-174: LGTM!

The retrieval method correctly:

  • Selects all SchemaEdgeKind fields including timestamps
  • Uses CheckError to map gorm.ErrRecordNotFound to ErrNotFound
  • Follows the pattern established by GetSchemaNodeKindByID
cmd/api/src/database/mocks/db.go (1)

543-556: LGTM!

The generated mock methods for CreateSchemaEdgeKind and GetSchemaEdgeKindById correctly implement the gomock pattern and match the interface signatures. The mocks will properly support unit testing of code that depends on these database operations.

Also applies to: 1893-1906


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
cmd/api/src/model/graphschema.go (1)

42-54: SchemaEdgeKind mapping looks correct; tighten comments and consider tags

The struct and TableName() correctly align with schema_edge_kinds (including schema_extension_id INTSchemaExtensionId int32 and the other columns), so the DB mapping looks good.

Two small nits you may want to address:

  • The comments say “node kind” and // indicates, which is a bit misleading/incomplete for an edge kind; updating to “edge kind” and a full description would avoid confusion.
  • GraphSchemaExtension uses json/validate tags; if SchemaEdgeKind is ever surfaced via the API, mirroring that style (e.g., json:"name" validate:"required") would keep things consistent. This can be deferred until you expose it beyond the DB layer.
cmd/api/src/database/graphschema_test.go (1)

80-145: Integration coverage for SchemaEdgeKind is solid; a couple of minor polish opportunities

The test flow (create two edge kinds, read-by-id, assert not-found, then assert duplicate-name maps to ErrDuplicateSchemaEdgeKindName) lines up well with the new DB methods and migration. The compareSchemaEdgeKind helper keeps the assertions focused on the important fields. No functional issues here.

A few small, optional refinements you might consider:

  • For the not-found case (Line 132–133), using require.ErrorIs(t, err, database.ErrNotFound) would be a bit more robust than asserting the string "entity not found", and would match how you’re already handling the duplicate-name sentinel.
  • The compareSchemaEdgeKind messages all say CreateSchemaEdgeKind - ... even when used after GetSchemaEdgeKindById; if you ever hit a failure while reading, that message might be slightly confusing. Renaming to something generic like SchemaEdgeKind - name - ... would make it reusable across both paths.

These are small test-quality tweaks; the current tests are still clear and effective.

cmd/api/src/database/migration/migrations/v8.5.0.sql (1)

42-54: DDL for schema_edge_kinds matches model and usage; only comment text is slightly off

The table definition looks consistent with the Go model and queries:

  • Column names/types align with model.SchemaEdgeKind and the INSERT/SELECT statements.
  • schema_extension_id FK with ON DELETE CASCADE and a separate index on that column are sensible for lookups by extension.
  • The uniqueness and regex constraint on name match the intent described in the comment and the duplicate-name error handling.

Two tiny nits:

  • The inline comment for schema_extension_id says “node kind”; updating it to “edge kind” would avoid confusion.
  • If you ever decide that edge-kind names should be unique only within an extension, you may want to change UNIQUE (name) to a composite unique over (schema_extension_id, name). If global uniqueness is the goal, the current definition is correct.

Nothing blocking here.

cmd/api/src/database/graphschema.go (3)

27-30: Consider exposing edge-kind operations via the OpenGraphSchema interface

You’ve added CreateSchemaEdgeKind / GetSchemaEdgeKindById on *BloodhoundDB, but OpenGraphSchema (and therefore Database) still only exposes the extension methods. If callers are meant to depend on the OpenGraphSchema/Database abstraction rather than the concrete *BloodhoundDB, it may be worth adding the new methods to the interface now so they’re available to services in the same way as the extension operations.

If you’re intentionally keeping these as internal helpers for now, then this can wait, but it’s an easy place for future drift between the interface and the concrete implementation.

Also applies to: 82-105


82-97: CreateSchemaEdgeKind implementation is correct and consistent with existing patterns

The insert logic looks good:

  • Uses parameterized INSERT ... RETURNING with schemaEdgeKind.TableName() so there’s no SQL injection risk.
  • Maps the Postgres unique-constraint string to ErrDuplicateSchemaEdgeKindName, matching how extensions handle ErrDuplicateGraphSchemaExtensionName.
  • Falls back to CheckError(result) for other DB errors, which will appropriately surface non-not-found failures.

One optional consideration: CreateGraphSchemaExtension runs inside AuditableTransaction with an AuditEntry, while edge-kind creation currently does not. If edge-kind definitions are considered configuration that should be audited, you might want to mirror that pattern later for consistency. Functionally, this is fine as-is.


99-105: GetSchemaEdgeKindById is functionally correct; style is slightly different from the extension version

This method correctly:

  • Queries by id using the same set of columns defined in the migration/model.
  • Relies on CheckError to translate gorm.ErrRecordNotFound into ErrNotFound, which aligns with how the tests assert the not-found case.

It’s a bit more compact than GetGraphSchemaExtensionById (which uses an explicit if result := ...; result.Error != nil { ... } block), but behavior is equivalent. If you prefer consistency, you could mirror that style; otherwise, this is fine.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fcd782f and d856a13.

📒 Files selected for processing (5)
  • cmd/api/src/database/db.go (1 hunks)
  • cmd/api/src/database/graphschema.go (1 hunks)
  • cmd/api/src/database/graphschema_test.go (1 hunks)
  • cmd/api/src/database/migration/migrations/v8.5.0.sql (1 hunks)
  • cmd/api/src/model/graphschema.go (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-22T20:30:34.839Z
Learnt from: LawsonWillard
Repo: SpecterOps/BloodHound PR: 1700
File: cmd/api/src/api/v2/saved_queries_test.go:3182-3182
Timestamp: 2025-07-22T20:30:34.839Z
Learning: In Go table-driven tests in cmd/api/src/api/v2/saved_queries_test.go, subtest parallelization with t.Parallel() is acceptable when tests are self-contained, each creating their own mock controller (gomock.NewController(t)) and having isolated mock expectations without shared state between subtests.

Applied to files:

  • cmd/api/src/database/graphschema_test.go
📚 Learning: 2025-06-06T23:12:14.181Z
Learnt from: elikmiller
Repo: SpecterOps/BloodHound PR: 1563
File: packages/go/graphschema/azure/azure.go:24-24
Timestamp: 2025-06-06T23:12:14.181Z
Learning: In BloodHound, files in packages/go/graphschema/*/`*.go` are generated from CUE schemas. When `just prepare-for-codereview` is run, it triggers code generation that may automatically add import aliases or other formatting changes. These changes are legitimate outputs of the generation process, not manual edits that would be overwritten.

Applied to files:

  • cmd/api/src/database/graphschema.go
🧬 Code graph analysis (3)
cmd/api/src/database/graphschema_test.go (3)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (43-50)
  • SchemaEdgeKind (52-54)
packages/go/graphschema/common/common.go (1)
  • Description (55-55)
cmd/api/src/database/db.go (1)
  • ErrDuplicateSchemaEdgeKindName (56-56)
cmd/api/src/model/graphschema.go (1)
packages/go/graphschema/common/common.go (1)
  • Description (55-55)
cmd/api/src/database/graphschema.go (3)
cmd/api/src/database/db.go (2)
  • BloodhoundDB (189-192)
  • ErrDuplicateSchemaEdgeKindName (56-56)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (43-50)
  • SchemaEdgeKind (52-54)
cmd/api/src/database/helper.go (1)
  • CheckError (26-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build BloodHound Container Image / Build and Package Container
  • GitHub Check: run-tests
  • GitHub Check: run-analysis
  • GitHub Check: build-ui
🔇 Additional comments (1)
cmd/api/src/database/db.go (1)

45-57: New duplicate edge-kind error aligns with existing patterns

ErrDuplicateSchemaEdgeKindName is consistent with other duplicate* sentinels and cleanly supports mapping the unique-constraint violation from schema_edge_kinds. No issues here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d856a13 and 0387ffe.

📒 Files selected for processing (1)
  • cmd/api/src/database/graphschema.go (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-06T23:12:14.181Z
Learnt from: elikmiller
Repo: SpecterOps/BloodHound PR: 1563
File: packages/go/graphschema/azure/azure.go:24-24
Timestamp: 2025-06-06T23:12:14.181Z
Learning: In BloodHound, files in packages/go/graphschema/*/`*.go` are generated from CUE schemas. When `just prepare-for-codereview` is run, it triggers code generation that may automatically add import aliases or other formatting changes. These changes are legitimate outputs of the generation process, not manual edits that would be overwritten.

Applied to files:

  • cmd/api/src/database/graphschema.go
🧬 Code graph analysis (1)
cmd/api/src/database/graphschema.go (3)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (43-50)
  • SchemaEdgeKind (52-54)
cmd/api/src/database/db.go (2)
  • BloodhoundDB (189-192)
  • ErrDuplicateSchemaEdgeKindName (56-56)
cmd/api/src/database/helper.go (1)
  • CheckError (26-32)
🪛 golangci-lint (2.5.0)
cmd/api/src/database/graphschema.go

[major] 103-103: : # github.com/specterops/bloodhound/cmd/api/src/api [github.com/specterops/bloodhound/cmd/api/src/api.test]
cmd/api/src/api/auth_internal_test.go:103:32: cannot use mockDB (variable of type *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase) as database.Database value in struct literal: *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:118:32: cannot use mockDB (variable of type *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase) as database.Database value in struct literal: *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:136:21: cannot use dbMocks.NewMockDatabase(ctrl) (value of type *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase) as database.Database value in struct literal: *"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:219:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:241:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:266:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:296:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:323:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:365:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:398:9: impossible type assertion: authenticator.db.(*dbMocks.MockDatabase)
*"github.com/specterops/bloodhound/cmd/api/src/database/mocks".MockDatabase does not implement database.Database (missing method CreateSchemaEdgeKind)
cmd/api/src/api/auth_internal_test.go:398:9: too many errors

(typecheck)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build BloodHound Container Image / Build and Package Container
  • GitHub Check: run-analysis
  • GitHub Check: build-ui
  • GitHub Check: run-tests
🔇 Additional comments (3)
cmd/api/src/database/graphschema.go (3)

31-32: LGTM!

The interface method signatures are well-structured and follow consistent patterns with the existing OpenGraphSchema methods.


103-108: LGTM!

The implementation follows the established pattern from GetGraphSchemaExtensionById and correctly handles errors through CheckError.


31-32: Regenerate mocks to include new interface methods.

The Database interface now embeds the OpenGraphSchema interface, which defines two new methods: CreateSchemaEdgeKind and GetSchemaEdgeKindById. The mock implementation at cmd/api/src/database/mocks/db.go does not yet include these methods.

Regenerate mocks by running:

go generate ./cmd/api/src/database/db.go

This will update mocks/db.go with the missing interface methods.

# Conflicts:
#	cmd/api/src/database/db.go
#	cmd/api/src/database/graphschema.go
#	cmd/api/src/database/graphschema_test.go
#	cmd/api/src/database/migration/migrations/v8.5.0.sql
#	cmd/api/src/database/mocks/db.go
#	cmd/api/src/model/graphschema.go
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cmd/api/src/model/graphschema.go (1)

67-67: Complete the inline documentation.

The comment on Line 67 is incomplete: // indicates should explain what IsTraversable indicates (e.g., "indicates whether the edge kind can be traversed in graph queries" or similar).

Apply this diff to complete the comment:

-	IsTraversable     bool // indicates
+	IsTraversable     bool // indicates whether the edge kind is traversable in graph queries
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0387ffe and 0d83a79.

📒 Files selected for processing (6)
  • cmd/api/src/database/db.go (1 hunks)
  • cmd/api/src/database/graphschema.go (2 hunks)
  • cmd/api/src/database/graphschema_test.go (1 hunks)
  • cmd/api/src/database/migration/migrations/v8.5.0.sql (1 hunks)
  • cmd/api/src/database/mocks/db.go (2 hunks)
  • cmd/api/src/model/graphschema.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/api/src/database/db.go
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: LawsonWillard
Repo: SpecterOps/BloodHound PR: 2107
File: cmd/api/src/database/graphschema.go:86-100
Timestamp: 2025-11-25T22:11:53.509Z
Learning: In cmd/api/src/database/graphschema.go, the CreateSchemaEdgeKind method intentionally does not use AuditableTransaction or audit logging because it would create too much noise in the audit log, unlike CreateGraphSchemaExtension which does use auditing.
📚 Learning: 2025-11-25T22:11:53.509Z
Learnt from: LawsonWillard
Repo: SpecterOps/BloodHound PR: 2107
File: cmd/api/src/database/graphschema.go:86-100
Timestamp: 2025-11-25T22:11:53.509Z
Learning: In cmd/api/src/database/graphschema.go, the CreateSchemaEdgeKind method intentionally does not use AuditableTransaction or audit logging because it would create too much noise in the audit log, unlike CreateGraphSchemaExtension which does use auditing.

Applied to files:

  • cmd/api/src/database/migration/migrations/v8.5.0.sql
  • cmd/api/src/model/graphschema.go
  • cmd/api/src/database/graphschema.go
  • cmd/api/src/database/mocks/db.go
  • cmd/api/src/database/graphschema_test.go
📚 Learning: 2025-06-06T23:12:14.181Z
Learnt from: elikmiller
Repo: SpecterOps/BloodHound PR: 1563
File: packages/go/graphschema/azure/azure.go:24-24
Timestamp: 2025-06-06T23:12:14.181Z
Learning: In BloodHound, files in packages/go/graphschema/*/`*.go` are generated from CUE schemas. When `just prepare-for-codereview` is run, it triggers code generation that may automatically add import aliases or other formatting changes. These changes are legitimate outputs of the generation process, not manual edits that would be overwritten.

Applied to files:

  • cmd/api/src/database/graphschema.go
🧬 Code graph analysis (3)
cmd/api/src/model/graphschema.go (1)
packages/go/graphschema/common/common.go (1)
  • Description (55-55)
cmd/api/src/database/mocks/db.go (1)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (61-68)
  • SchemaEdgeKind (70-72)
cmd/api/src/database/graphschema_test.go (2)
cmd/api/src/model/graphschema.go (2)
  • SchemaEdgeKind (61-68)
  • SchemaEdgeKind (70-72)
cmd/api/src/database/db.go (1)
  • ErrDuplicateSchemaEdgeKindName (57-57)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build BloodHound Container Image / Build and Package Container
  • GitHub Check: run-analysis
  • GitHub Check: build-ui
  • GitHub Check: run-tests
# Conflicts:
#	cmd/api/src/database/db.go
#	cmd/api/src/database/graphschema.go
#	cmd/api/src/database/graphschema_test.go
#	cmd/api/src/database/migration/migrations/v8.5.0.sql
#	cmd/api/src/model/graphschema.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A pull request containing changes affecting the API code. enhancement New feature or request

2 participants