{"record":{"id":"ff579118a2152ad0","repo":"apereo/cas","slug":"e-getmessage-resourcenotfoundexception-logged-d","errorCode":null,"errorMessage":"e.getMessage() (ResourceNotFoundException logged during deleteAll)","messagePattern":"e\\.getMessage\\(\\) \\(ResourceNotFoundException logged during deleteAll\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"support/cas-server-support-dynamodb-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/DynamoDbTicketRegistryFacilitator.java","lineNumber":164,"sourceCode":"     * @return the int\n     */\n    public int deleteAll() {\n        val deletor = new Supplier<Integer>() {\n            @Override\n            public Integer get() {\n                val count = new AtomicInteger();\n                val metadata = ticketCatalog.findAll();\n                metadata.forEach(definition -> {\n                    val tableName = definition.getProperties().getStorageName();\n                    count.addAndGet(Math.toIntExact(deleteTickets(tableName, scanTicketIds(tableName))));\n                });\n                return count.get();\n            }\n        };\n        try {\n            return deletor.get();\n        } catch (final ResourceNotFoundException e) {\n            LOGGER.warn(e.getMessage(), e);\n            createTicketTables(false);\n            return deletor.get();\n        }\n    }\n\n    /**\n     * Scan and paginate.\n     *\n     * @return the stream\n     */\n    public Stream<Ticket> stream() {\n        val metadata = ticketCatalog.findAll();\n        val resultStreams = metadata\n            .stream()\n            .map(defn -> queryTicketsByIndex(defn.getProperties().getStorageName(),\n                PREFIX_INDEX_NAME, ColumnNames.PREFIX, defn.getPrefix(), 0, true))\n            .toList();\n        return Streams.concat(resultStreams.toArray(new Stream[0]));","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-dynamodb-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/DynamoDbTicketRegistryFacilitator.java#L146-L182","documentation":"DynamoDbTicketRegistryFacilitator.deleteAll() runs a batch deletion of all tickets via a deletor callable. If DynamoDB throws ResourceNotFoundException (the ticket table does not exist), the code logs the exception message at WARN, recreates the missing ticket tables via createTicketTables(false), and retries the deletion once. The error item here is the WARN log line — an application-level recovery, not a thrown exception to callers.","triggerScenarios":"Calling deleteAll() (e.g. purge-all tickets operation or scheduled cleanup) when the DynamoDB table backing the ticket registry does not exist: fresh environment before table auto-creation, tables deleted manually in AWS console, wrong region/profile/table-prefix configuration pointing to a nonexistent table, or IAM/region mismatch.","commonSituations":"Deploying CAS against a new DynamoDB account/region without letting CAS create its tables; someone dropped the CAS ticket tables; cas.ticket.registry.dynamo-db table-prefix mismatch between nodes; using a DynamoDB endpoint (local test container) that was wiped between runs.","solutions":["Let the built-in recovery work: the registry recreates tables and retries; confirm logs show 'createTicketTables' succeeding afterwards","Verify cas.ticket.registry.dynamo-db settings (region, endpoint, table prefix) match the actual DynamoDB environment","Check AWS IAM permissions for CreateTable/DeleteItem on the configured tables","If tables were deleted intentionally, restart CAS or trigger table creation so state is consistent","For local dev, start the DynamoDB test container (ci tests) before running registry operations"],"exampleFix":"// before: region mismatch — table exists in us-east-1, CAS looks in eu-west-1\n# cas.ticket.registry.dynamo-db.region=eu-west-1\n// after\ncas.ticket.registry.dynamo-db.region=us-east-1","handlingStrategy":"retry","validationCode":"// Before deleteAll, confirm the table exists:\nDescribeTableRequest req = DescribeTableRequest.builder()\n    .tableName(tableName).build();\ndynamoDbClient.describeTable(req); // throws ResourceNotFoundException if missing","typeGuard":null,"tryCatchPattern":"try {\n    return deletor.get();\n} catch (ResourceNotFoundException e) {\n    LOGGER.warn(e.getMessage(), e);\n    createTicketTables(false);   // recreate, then retry once\n    return deletor.get();\n}","preventionTips":["Pin the AWS region and endpoint configuration used by the ticket registry","Grant IAM permissions for both DescribeTable/CreateTable and item operations","Use a consistent table prefix across all CAS nodes","In dev, keep the DynamoDB local container volume persistent so tables survive restarts"],"tags":["dynamodb","ticket-registry","aws","recovery"],"backgroundTag":"resource-not-found","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}