{"record":{"id":"c5edb39aa51544ae","repo":"apereo/cas","slug":"metadata-artifacts-are-available-at-the-specified","errorCode":null,"errorMessage":"Metadata artifacts are available at the specified location [{}]","messagePattern":"Metadata artifacts are available at the specified location \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/saml/GenerateSamlIdPMetadataCommand.java","lineNumber":110,"sourceCode":"            description = \"Comma separated list of other subject alternative names for the certificate (besides entityId)\",\n            defaultValue = StringUtils.EMPTY\n        )\n        final String subjectAltNames\n    ) throws Throwable {\n\n        val locator = new FileSystemSamlIdPMetadataLocator(CipherExecutor.noOpOfStringToString(),\n            new File(metadataLocation),\n            Caffeine.newBuilder().initialCapacity(1).maximumSize(1).build(),\n            applicationContext);\n        val writer = new DefaultSamlIdPCertificateAndKeyWriter(entityId);\n        if (StringUtils.isNotBlank(subjectAltNames)) {\n            writer.setUriSubjectAltNames(List.of(StringUtils.split(subjectAltNames, \",\")));\n        }\n\n        val generateMetadata = FunctionUtils.doIf(locator.exists(Optional.empty()),\n            () -> Boolean.TRUE,\n            () -> {\n                LOGGER.warn(\"Metadata artifacts are available at the specified location [{}]\", metadataLocation);\n                return force;\n            }).get();\n\n        if (generateMetadata) {\n            val props = new CasConfigurationProperties();\n            props.getAuthn().getSamlIdp().getCore().setEntityId(entityId);\n            props.getServer().setScope(scope);\n            props.getServer().setPrefix(serverPrefix);\n\n            val context = SamlIdPMetadataGeneratorConfigurationContext.builder()\n                .samlIdPMetadataLocator(locator)\n                .samlIdPCertificateAndKeyWriter(writer)\n                .applicationContext(applicationContext)\n                .casProperties(props)\n                .metadataCipherExecutor(CipherExecutor.noOpOfStringToString())\n                .openSamlConfigBean(openSamlConfigBean)\n                .velocityEngine(velocityEngineFactoryBean)\n                .build();","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/saml/GenerateSamlIdPMetadataCommand.java#L92-L128","documentation":"GenerateSamlIdPMetadataCommand.generate() checks whether metadata artifacts already exist at the target location via the metadata locator. If they already exist it logs this warning; generation only proceeds when --force is supplied (or the location is empty). This prevents silently overwriting an existing IdP metadata keystore/certificates.","triggerScenarios":"Running 'cas generate-saml-idp-metadata' (or the equivalent shell command) with --metadataLocation pointing at a directory that already contains IdP metadata artifacts, without --force.","commonSituations":"Re-running the metadata generation command after a previous successful run; pointing at a directory already populated by the IdP; scripted re-provisioning that reuses the same metadata directory.","solutions":["Add --force to regenerate and overwrite the existing metadata artifacts","Use a different --metadataLocation for a fresh generation","Verify existing metadata is backed up before forcing regeneration","If artifacts are current, do nothing — generation is intentionally skipped"],"exampleFix":"// before\ncas generate-saml-idp-metadata --metadataLocation /etc/cas/saml/idp\n// after\ncas generate-saml-idp-metadata --metadataLocation /etc/cas/saml/idp --force","handlingStrategy":"validation","validationCode":"File dir = new File(metadataLocation);\nboolean exists = dir.exists() && new File(dir, \"idp-metadata.xml\").exists(); // or run the locator check\nif (exists && !force) System.out.println(\"Metadata already present; pass --force to regenerate\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use unique metadata locations per environment to avoid accidental overwrites","Back up the metadata directory before using --force","Make generation scripts idempotent by checking the locator first"],"tags":["saml","cli","idempotency","metadata"],"backgroundTag":"file-already-exists","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"}