{"record":{"id":"ee5348051473261f","repo":"microsoft/aspire","slug":"adminpassword","errorCode":null,"errorMessage":"adminPassword","messagePattern":"adminPassword","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Keycloak/KeycloakResource.cs","lineNumber":42,"sourceCode":"    /// <summary>\n    /// Features to disable for the keycloak resource\n    /// </summary>\n    internal HashSet<string> DisabledFeatures { get; } = new();\n\n    /// <summary>\n    /// Gets the parameter that contains the Keycloak admin.\n    /// </summary>\n    public ParameterResource? AdminUserNameParameter { get; } = admin;\n\n    internal ReferenceExpression AdminReference =>\n        AdminUserNameParameter is not null ?\n            ReferenceExpression.Create($\"{AdminUserNameParameter}\") :\n            ReferenceExpression.Create($\"{DefaultAdmin}\");\n\n    /// <summary>\n    /// Gets the parameter that contains the Keycloak admin password.\n    /// </summary>\n    public ParameterResource AdminPasswordParameter { get; } = adminPassword ?? throw new ArgumentNullException(nameof(adminPassword));\n}\n","sourceCodeStart":24,"sourceCodeEnd":44,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Keycloak/KeycloakResource.cs#L24-L44","documentation":"KeycloakResource's constructor requires an admin password parameter resource. When the adminPassword argument is null, the property initializer throws ArgumentNullException(nameof(adminPassword)). This ensures every Keycloak resource always has a ParameterResource that supplies the admin password at runtime.","triggerScenarios":"Constructing KeycloakResource directly, or calling the AddKeycloak overload with a null adminPassword parameter resource.","commonSituations":"Developers write custom factory code that creates a KeycloakResource without wiring up a password parameter, or accidentally pass null instead of builder.AddParameter(\"...\") result.","solutions":["Create a parameter with builder.AddParameter(\"keycloak-admin-password\", secret: true) and pass it as adminPassword.","Use the standard AddKeycloak extension which supplies the parameter automatically.","If you need a generated password, use ParameterResource with a generated default value rather than null."],"exampleFix":"// before\nvar kc = new KeycloakResource(\"keycloak\", adminPassword: null);\n\n// after\nvar password = builder.AddParameter(\"keycloak-admin-password\", secret: true);\nvar kc = new KeycloakResource(\"keycloak\", password);","handlingStrategy":"validation","validationCode":"if (adminPassword is null) throw new ArgumentNullException(nameof(adminPassword)); // check before constructing KeycloakResource","typeGuard":"bool HasPassword(KeycloakResource r) => r.AdminPasswordParameter is not null;","tryCatchPattern":null,"preventionTips":["Use the AddKeycloak extension rather than constructing KeycloakResource manually.","Create password parameters with builder.AddParameter(..., secret: true)."],"tags":["keycloak","null-argument","parameter","aspire"],"backgroundTag":"null-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}