{"record":{"id":"b34868455c496f28","repo":"apache/druid","slug":"unknown-schema-s","errorCode":null,"errorMessage":"Unknown schema %s","messagePattern":"Unknown schema (.+?)","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"extensions-core/druid-catalog/src/main/java/org/apache/druid/catalog/http/CatalogResource.java","lineNumber":560,"sourceCode":"    }\n\n    if (!schema.accepts(spec.type())) {\n      throw CatalogException.badRequest(\n          \"Cannot create tables of type %s in schema %s\",\n          spec.type(),\n          schema.name()\n      );\n    }\n  }\n\n  private SchemaSpec validateSchema(String schemaName, boolean forWrite) throws CatalogException\n  {\n    if (Strings.isNullOrEmpty(schemaName)) {\n      throw CatalogException.badRequest(\"Schema name is required\");\n    }\n    SchemaSpec schema = catalog.resolveSchema(schemaName);\n    if (schema == null) {\n      throw new NotFoundException(\"Unknown schema %s\", schemaName);\n    }\n\n    if (forWrite && !schema.writable()) {\n      throw CatalogException.badRequest(\n          \"Cannot modify schema %s\",\n          schemaName\n      );\n    }\n    return schema;\n  }\n\n  private static ResourceAction resourceAction(SchemaSpec schema, String tableName, Action action)\n  {\n    return new ResourceAction(new Resource(tableName, schema.securityResource()), action);\n  }\n\n  private void authorizeTable(\n      final SchemaSpec schema,","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-catalog/src/main/java/org/apache/druid/catalog/http/CatalogResource.java#L542-L578","documentation":"CatalogResource.validateSchema() resolves the requested schema name against the catalog and returns 404 Not Found when no SchemaSpec matches. It is a request-level guard so that operations against a nonexistent schema (read or write) fail early with a clear message instead of a null-pointer deeper in the resource.","triggerScenarios":"HTTP calls to /druid-ext/v1/catalog/... with a schemaName that does not exist in the catalog (e.g. GET/POST/DELETE on a misspelled or never-created schema).","commonSituations":"Typos in schema names in automation scripts ('DRUID' vs 'druid'); referring to a schema deleted by another operator; assuming the default 'druid' schema exists when catalog tables have never been provisioned.","solutions":["List the existing schemas (GET /druid-ext/v1/catalog/schemas or via the catalog view) and use an exact existing name.","Fix the schema name spelling/case in the request and retry.","Create/provision the schema first if it is supposed to exist, then re-run the operation."],"exampleFix":"// before\ncurl .../catalog/tables?schema=DRUID_ARCHIVES\n\n// after\ncurl .../catalog/schemas          # confirm available names\ncurl .../catalog/tables?schema=druid","handlingStrategy":"validation","validationCode":"const schemas = await fetch('/druid-ext/v1/catalog/schemas').then(r => r.json());\nfunction schemaExists(name) {\n  return schemas.some(s => s.name === name);\n}\nif (!schemaExists('druid')) throw new Error('schema not found');","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(url);\n  if (res.status === 404) {\n    const available = await fetch('/druid-ext/v1/catalog/schemas').then(r => r.json());\n    throw new Error(`Schema not found; available: ${available.map(s => s.name)}`);\n  }\n} catch (e) { /* handle */ }","preventionTips":["Fetch and cache the schema list once before catalog automation runs.","Use exact, case-sensitive schema names copied from the catalog API, not from memory.","Treat schema deletion by other operators as possible; re-check before long-running scripts."],"tags":["catalog","http-404","schema"],"backgroundTag":"resource-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}