* fix(import): tolerate only typed dependency refusals, not walk-query errors With SkipDependencyValidationErrors set (the import mode), the dependency pass recorded ANY error from checkHierarchy/checkCycle as a skipped edge and continued. That included failed walk queries (an untranslated statement, a statement timeout, a dropped connection), so an import could commit without the edge and report the SQL error only as a skip reason; on a backend whose transaction aborts on a failed statement, the import failed later at an unrelated statement with the real cause hidden. Tolerate only the typed refusals (ErrSelfDependency, ErrDependencyCycle, *DependencyHierarchyConflictError) via isDependencyValidationRefusal and return every other error, keeping the %w chain so serialization retry and error classification apply. Tests: sqlmock cases where the hierarchy and cycle walks fail under import mode, on both the per-edge statements and the batch graph, must abort the pass; typed refusals on both shapes are still skipped. Removing the predicate fails both error tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(import): record the dependency-check fix in the CHANGELOG; tidy two test comments Review fixups for #7630. - CHANGELOG (Unreleased, Fixed): bd import now fails when a dependency check's own query fails, instead of reporting the SQL error as a skipped dependency and, on Dolt, committing without the edge. Refused edges (a self-dependency, a cycle, a hierarchy conflict) are still skipped. docs/ is left alone because it tracks the pinned release (v1.2.2). - create_test.go: two doc comments kept the line breaks left where the internal tracker IDs were removed. They are reflowed into sentences; no test logic changes. Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
46 lines
2.7 KiB
Go
46 lines
2.7 KiB
Go
// Package storage defines the interface for issue storage backends.
|
|
package storage
|
|
|
|
// BatchCreateOptions contains options for batch issue creation.
|
|
// This is a backend-agnostic type that can be used by any storage implementation.
|
|
type BatchCreateOptions struct {
|
|
// CreateOnly uses strict insert semantics after the caller has reserved the
|
|
// issue ID. It is for guarded public creates; import behavior is unchanged.
|
|
CreateOnly bool
|
|
// SkipPrefixValidation skips prefix validation for existing IDs (used during import)
|
|
SkipPrefixValidation bool
|
|
// ConflictSkip makes batch creation insert-if-new instead of UPSERT: an
|
|
// issue whose ID already exists is left untouched rather than overwritten.
|
|
// Used only by the auto-import upgrade-recovery fallback (GH#3955), so
|
|
// that if the emptiness guard in maybeAutoImportJSONL ever regresses
|
|
// again (cf. PR #3630), auto-import degrades to a harmless no-op instead
|
|
// of clobbering live rows. Explicit `bd import` keeps UPSERT semantics.
|
|
ConflictSkip bool
|
|
// RejectStaleUpserts makes the issue-row UPSERT conditional on updated_at:
|
|
// the incoming row only rewrites the stored columns when it is strictly
|
|
// newer. A stored row that is strictly newer is rejected outright
|
|
// (OnStaleRejected fires, aux data skipped); an equal-timestamp row keeps
|
|
// every stored column but still merges its aux data — updated_at has
|
|
// second granularity, so a tie may be two distinct same-second updates
|
|
// and the local row wins it (bd-hj85c). This is the transactional half
|
|
// of the import stale guard (bd-pkim8): cmd/bd's filterStaleImportIssues
|
|
// reads local updated_at before the batch write, so a local update
|
|
// committing in between would otherwise be silently overwritten (the
|
|
// PR 4204 race). Set by `bd import` unless --allow-stale; create paths
|
|
// leave it false.
|
|
RejectStaleUpserts bool
|
|
// SkipDependencyValidationErrors skips dependency validation failures that
|
|
// legacy imports tolerated: typed refusals of an edge (a cycle, a
|
|
// self-dependency, or a blocker in the issue's own hierarchy). An error
|
|
// from the validation queries themselves is still returned, never recorded
|
|
// as a skipped edge.
|
|
SkipDependencyValidationErrors bool
|
|
// OnSkippedDependency records dependency edges skipped during batch create.
|
|
OnSkippedDependency func(issueID, dependsOnID, reason string)
|
|
// OnStaleRejected records issues whose row the RejectStaleUpserts guard
|
|
// kept (stored row strictly newer than the incoming one). Rejected issues
|
|
// also skip label/comment/dependency persistence, so callers can count
|
|
// them as skipped rather than created. May fire more than once per issue
|
|
// if the enclosing transaction retries; callers should dedup by ID.
|
|
OnStaleRejected func(issueID string)
|
|
}
|