{"record":{"id":"ded3119721f4be24","repo":"apereo/cas","slug":"file-is-does-not-exist-is-not-readable-or-is-ded311","errorCode":null,"errorMessage":"File [{}] is does not exist, is not readable or is empty","messagePattern":"File \\[(.+?)\\] is does not exist, is not readable or is empty","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/ValidateRegisteredServiceCommand.java","lineNumber":79,"sourceCode":"                FileUtils.listFiles(directoryPath, new String[]{\"json\", \"yml\", \"yaml\"}, false)\n                    .forEach(this::validate);\n            }\n        }\n    }\n\n    private void validate(final File filePath) {\n        try {\n            val basicFileAttributes = Files.readAttributes(filePath.toPath(), BasicFileAttributes.class);\n            if (basicFileAttributes.isRegularFile() && filePath.exists()\n                && filePath.canRead() && basicFileAttributes.size() > 0) {\n                val validator = switch (FilenameUtils.getExtension(filePath.getPath()).toLowerCase(Locale.ENGLISH)) {\n                    case \"yml\", \"yaml\" -> new RegisteredServiceYamlSerializer(applicationContext);\n                    default -> new RegisteredServiceJsonSerializer(applicationContext);\n                };\n                val svc = Objects.requireNonNull(validator).from(filePath);\n                LOGGER.info(\"Service [{}] is valid at [{}].\", svc.getName(), filePath.getCanonicalPath());\n            } else {\n                LOGGER.warn(\"File [{}] is does not exist, is not readable or is empty\", filePath.getCanonicalPath());\n            }\n        } catch (final Exception e) {\n            LOGGER.error(\"Could not understand and validate [{}]: [{}]\", filePath.getPath(), e.getMessage());\n        } finally {\n            LOGGER.info(\"-\".repeat(SEP_LINE_LENGTH));\n        }\n    }\n}\n","sourceCodeStart":61,"sourceCodeEnd":88,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/ValidateRegisteredServiceCommand.java#L61-L88","documentation":"ValidateRegisteredServiceCommand.validate() logs this warning when the service definition file passed for validation does not exist, is not readable, or is empty. Without file content the command cannot deserialize the service, so it skips validation and logs an error path separately if parsing fails.","triggerScenarios":"Running 'cas validate-registered-service' with --file pointing at a missing path, unreadable file, or zero-byte file; the file extension selects the serializer (json default, yaml/yml for YAML).","commonSituations":"Wrong path or typo when validating service definitions; empty placeholder file created by an editor; permissions dropped after a deployment; testing validation before ever copying the service file to the host.","solutions":["Pass the absolute path to an existing, non-empty service definition file","Confirm read permissions on the file for the shell user","Ensure the file actually contains a serialized service (JSON or YAML per extension)","Use the .yaml/.yml extension only for YAML service definitions, .json for JSON"],"exampleFix":"// before\ncas validate-registered-service --file /etc/cas/services/missing.json\n// after\ncas validate-registered-service --file /etc/cas/services/ExampleService-100.json","handlingStrategy":"validation","validationCode":"File f = new File(path);\nif (!f.isFile() || !f.canRead() || f.length() == 0)\n    throw new IllegalArgumentException(\"Service file missing/empty/unreadable: \" + path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match file extension to format: .json for JSON, .yaml/.yml for YAML services","Validate paths in deployment scripts before invoking the shell command","Keep service files owned/readable by the CAS runtime user"],"tags":["filesystem","cli","registered-services","validation"],"backgroundTag":"file-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"}