Skip to content

Fix GORM column names and slice accumulation in Dependency cycle check #913

@coderabbitai

Description

@coderabbitai

Bug Description

In migration/v19/model/application.go, the Dependency.BeforeCreate() method has two issues in its cycle detection logic:

1. Incorrect GORM Column Name

The query uses struct field name "ToID" instead of the expected database column name "to_id". This causes the query to silently miss rows and fail to detect cycles properly.

2. Slice Accumulation Bug

The nextDeps slice is never reset between iterations, causing stale/duplicated results to accumulate across loop iterations.

Location

  • File: migration/v19/model/application.go
  • Method: Dependency.BeforeCreate() (lines ~93-111)

Fix Required

  1. Change query to use DB column name: db.Where("to_id IN ?", nextAppsIDs).Find(&nextDeps)
  2. Reset slice each iteration: nextDeps = nextDeps[:0] before the query

References

Metadata

Metadata

Assignees

Labels

needs-kindIndicates an issue or PR lacks a `kind/foo` label and requires one.needs-priorityIndicates an issue or PR lacks a `priority/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

No type

Projects

Status

🆕 New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions