fix(dolt): add ID generation to transaction CreateIssue
The doltTransaction.CreateIssue method was missing ID generation logic that exists in the SQLite transaction implementation. When issues were created within a transaction with empty IDs (like during wisp creation), they would all get empty string "" as the primary key, causing "duplicate primary key given: []" errors. This fix adds the same ID generation logic from SQLite transaction: - Get config prefix from database - Apply IDPrefix/PrefixOverride to determine effective prefix - Generate hash-based ID using generateIssueID Fixes wisp creation failures across all rigs running Dolt server mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,33 @@ func (t *doltTransaction) CreateIssue(ctx context.Context, issue *types.Issue, a
|
||||
issue.ContentHash = issue.ComputeContentHash()
|
||||
}
|
||||
|
||||
// Generate ID if not provided (critical for wisp creation)
|
||||
if issue.ID == "" {
|
||||
// Get prefix from config
|
||||
var configPrefix string
|
||||
err := t.tx.QueryRowContext(ctx, "SELECT value FROM config WHERE `key` = ?", "issue_prefix").Scan(&configPrefix)
|
||||
if err == sql.ErrNoRows || configPrefix == "" {
|
||||
return fmt.Errorf("database not initialized: issue_prefix config is missing")
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("failed to get config: %w", err)
|
||||
}
|
||||
|
||||
// Determine effective prefix
|
||||
prefix := configPrefix
|
||||
if issue.PrefixOverride != "" {
|
||||
prefix = issue.PrefixOverride
|
||||
} else if issue.IDPrefix != "" {
|
||||
prefix = configPrefix + "-" + issue.IDPrefix
|
||||
}
|
||||
|
||||
// Generate ID
|
||||
generatedID, err := generateIssueID(ctx, t.tx, prefix, issue, actor)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate issue ID: %w", err)
|
||||
}
|
||||
issue.ID = generatedID
|
||||
}
|
||||
|
||||
return insertIssueTx(ctx, t.tx, issue)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user