{"record":{"id":"ed2500ca38ce82d7","repo":"t8y2/dbx","slug":"synonym-target-is-missing-s-s","errorCode":null,"errorMessage":"synonym target is missing: %s.%s","messagePattern":"synonym target is missing: (.+?)\\.(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/xugu/main.go","lineNumber":3572,"sourceCode":"\t}\n\tif comment := strings.TrimSpace(xuguString(sequence.Comment)); comment != \"\" {\n\t\tbuilder.WriteString(\"\\n  COMMENT \")\n\t\tbuilder.WriteString(quoteStringLiteral(comment))\n\t}\n\tbuilder.WriteString(\";\")\n\treturn builder.String()\n}\n\n// getSynonymSource reconstructs synonym DDL from ALL_SYNONYMS. Public\n// synonyms are exposed in the reserved database-global scope and therefore\n// use PUBLIC syntax without a schema qualifier.\nfunc (s *server) getSynonymSource(schema, name string) (map[string]any, error) {\n\tsynonym, err := s.resolveCatalogSynonym(schema, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif strings.TrimSpace(synonym.TargetName) == \"\" {\n\t\treturn nil, fmt.Errorf(\"synonym target is missing: %s.%s\", synonym.Schema, synonym.Name)\n\t}\n\n\tvar builder strings.Builder\n\tif synonym.Public {\n\t\tbuilder.WriteString(\"CREATE PUBLIC SYNONYM \")\n\t\tbuilder.WriteString(quoteIdentifier(synonym.Name))\n\t} else {\n\t\tbuilder.WriteString(\"CREATE SYNONYM \")\n\t\tbuilder.WriteString(quoteIdentifier(synonym.Schema))\n\t\tbuilder.WriteByte('.')\n\t\tbuilder.WriteString(quoteIdentifier(synonym.Name))\n\t}\n\tbuilder.WriteString(\"\\nFOR \")\n\tif targetSchema := strings.TrimSpace(synonym.TargetSchema.String); targetSchema != \"\" {\n\t\tbuilder.WriteString(quoteIdentifier(targetSchema))\n\t\tbuilder.WriteByte('.')\n\t}\n\tbuilder.WriteString(quoteIdentifier(synonym.TargetName))","sourceCodeStart":3554,"sourceCodeEnd":3590,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/xugu/main.go#L3554-L3590","documentation":"getSynonymSource resolved a synonym in the XuguDB catalog, but the synonym's TargetName is empty, meaning the catalog row exists yet points at nothing (a dangling synonym). The driver refuses to emit a CREATE SYNONYM statement because its target cannot be determined. This is thrown before any DDL string is rendered.","triggerScenarios":"Calling the driver's synonym/source extraction path (getSynonymSource via schema-object DDL reconstruction) for a synonym whose catalog row has an empty TargetName — e.g. a synonym created against an object that was later dropped or a manually inserted/blank catalog entry.","commonSituations":"Dropping the underlying table/view/procedure without dropping the synonym first; database migrations that recreate objects under new names; corrupted or partially restored catalogs where the synonym target reference was lost.","solutions":["Query ALL_SYNONYMS (or the XuguDB equivalent) for the synonym and inspect its target column to confirm it is empty.","Recreate the synonym with a valid target: DROP SYNONYM schema.name; CREATE SYNONYM schema.name FOR new_target;","If the synonym is truly dangling and unneeded, drop it so catalog-driven DDL extraction no longer trips on it.","If the target exists but the catalog field is blank, raise the issue with the DBA/XuguDB support — this indicates catalog corruption or a restore issue."],"exampleFix":"-- before: dangling synonym\nCREATE SYNONYM app.orders FOR sales.orders;  -- sales.orders later dropped\nSELECT get_ddl('app', 'orders'); -- error: synonym target is missing: app.orders\n\n-- after\nCREATE SYNONYM app.orders FOR sales2.orders; -- point at an existing object","handlingStrategy":"validation","validationCode":"rows, _ := db.Query(`SELECT TARGET_NAME FROM ALL_SYNONYMS WHERE UPPER(SCHEMA_NAME)=UPPER(?) AND UPPER(SYNONYM_NAME)=UPPER(?)`, schema, name)\nvar target sql.NullString\nif rows.Next() { rows.Scan(&target) }\nrows.Close()\nif !target.Valid || strings.TrimSpace(target.String) == \"\" { return fmt.Errorf(\"synonym %s.%s has no target; fix catalog first\", schema, name) }","typeGuard":null,"tryCatchPattern":"var synErr *SynonymTargetMissingError\nif errors.As(err, &synErr) { log.Warn(\"skipping dangling synonym\", synErr.Schema, synErr.Name); continue }","preventionTips":["Drop synonyms together with their target objects in migrations.","Audit catalogs periodically for synonyms with NULL/empty targets.","Use foreign-key-like discipline: recreate targets before restoring synonyms."],"tags":["database","ddl","synonym","catalog"],"backgroundTag":"synonym-target-missing","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}