t8y2/dbx · error

sequence not found: %s.%s

Error message

sequence not found: %s.%s

What it means

The sequence resolver matches a schema-qualified sequence name against catalog candidates. When no candidate matches it returns 'sequence not found: <schema>.<name>'. This occurs while resolving sequence metadata or rendering sequence DDL.

Source

Thrown at agents/drivers/xugu/main.go:3512

		candidates = append(candidates, candidate)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return candidates, nil
}

func selectXuguCatalogSequenceName(schema, name string, candidates []xuguCatalogSequenceName) (string, string, error) {
	for _, candidate := range candidates {
		if candidate.Schema == schema && candidate.Name == name {
			return candidate.Schema, candidate.Name, nil
		}
	}
	if len(candidates) == 1 {
		return candidates[0].Schema, candidates[0].Name, nil
	}
	if len(candidates) == 0 {
		return "", "", fmt.Errorf("sequence not found: %s.%s", schema, name)
	}
	return "", "", fmt.Errorf("sequence name is ambiguous: %s.%s; specify the catalog's exact case", schema, name)
}

func renderXuguSequenceDDL(sequence xuguSequenceMetadata) string {
	var builder strings.Builder
	builder.WriteString("CREATE SEQUENCE ")
	builder.WriteString(quoteIdentifier(sequence.Schema))
	builder.WriteByte('.')
	builder.WriteString(quoteIdentifier(sequence.Name))

	if value := xuguSequenceNumber(sequence.Step); value != "" {
		builder.WriteString("\n  INCREMENT BY ")
		builder.WriteString(value)
	}
	if value := xuguSequenceNumber(sequence.Current); value != "" {
		builder.WriteString("\n  START WITH ")
		builder.WriteString(value)

View on GitHub (pinned to c0390bff16)

Solutions

  1. List sequences in the target schema (or search all schemas) and use an existing schema.name pair.
  2. Correct the schema qualifier — the sequence may exist under a different schema.
  3. Reconnect to the database that actually contains the sequence.
  4. Refresh stale metadata caches and retry.

Example fix

// before
getSequenceDDL("app", "order_seq") // not found
// after
seqs := listSequences() // shows "sales.order_seq"
getSequenceDDL("sales", "order_seq")
Defensive patterns

Strategy: validation

Validate before calling

seqs := listSequences(schema)
if !contains(seqs, name) {
  return fmt.Errorf("%s.%s not in catalog", schema, name)
}

Try / catch

if err := getSequenceDDL(schema, name); err != nil {
  if strings.Contains(err.Error(), "sequence not found") {
    schema, name = locateSequenceGlobally(name) // search other schemas/dbs
    getSequenceDDL(schema, name)
  }
}

Prevention

When it happens

Trigger: Requesting sequence metadata/DDL for schema.name where no such sequence exists in the catalog — wrong schema, wrong sequence name, or the sequence was dropped/renamed.

Common situations: Copy-pasted DDL referencing another environment's schema; misspelled schema or sequence name; sequence lives in a different database; tooling generating DDL from stale metadata caches.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/ba92db9598fb1204. Report an issue: GitHub.