{"record":{"id":"3f57b7d4a2280561","repo":"quarkusio/quarkus","slug":"cardaction-requires-either-jsonrpcmethodname-or","errorCode":null,"errorMessage":"CardAction requires either jsonRpcMethodName() or url()","messagePattern":"CardAction requires either jsonRpcMethodName\\(\\) or url\\(\\)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/page/CardActionBuilder.java","lineNumber":52,"sourceCode":"    }\n\n    public CardActionBuilder url(String url) {\n        this.actionType = CardAction.ActionType.URL;\n        this.actionReference = url;\n        return this;\n    }\n\n    public CardActionBuilder showResultNotification(boolean show) {\n        this.showResultNotification = show;\n        return this;\n    }\n\n    public CardAction build() {\n        if (title == null || title.isEmpty()) {\n            throw new RuntimeException(\"CardAction title is required\");\n        }\n        if (actionType == null || actionReference == null || actionReference.isEmpty()) {\n            throw new RuntimeException(\"CardAction requires either jsonRpcMethodName() or url()\");\n        }\n        return new CardAction(title, icon, tooltip,\n                actionType, actionReference, showResultNotification);\n    }\n}\n","sourceCodeStart":34,"sourceCodeEnd":58,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/page/CardActionBuilder.java#L34-L58","documentation":"CardActionBuilder.build() requires an actionType plus a non-empty actionReference. An action must point somewhere — either a JSON-RPC method name (jsonRpcMethodName(...)) or a URL (url(...)). Building without either leaves the Dev UI button with no target, so the library fails fast.","triggerScenarios":"Calling CardActionBuilder.build() after setting only title/icon/tooltip/showResultNotification, or calling jsonRpcMethodName(null) / url(\"\") so actionType or actionReference stays null/empty.","commonSituations":"Extension authors defining card action buttons but forgetting to wire the click target; conditional code where both url() and jsonRpcMethodName() calls are skipped at runtime; refactors that renamed the RPC method string to an empty variable.","solutions":["Call either jsonRpcMethodName(\"myRpcMethod\") or url(\"https://...\") on the builder before build()","Ensure the JSON-RPC method exists in a @JsonRpc class registered for Dev UI and its name matches exactly","If the target is conditional, guard build() and skip creating the CardAction entirely when neither target is available","Log/assert the builder state in tests that construct Dev UI pages"],"exampleFix":"// before\nCardAction action = new CardActionBuilder()\n        .title(\"Refresh\")\n        .build(); // throws\n// after\nCardAction action = new CardActionBuilder()\n        .title(\"Refresh\")\n        .jsonRpcMethodName(\"refreshData\")\n        .build();","handlingStrategy":"validation","validationCode":"boolean ready = (title != null && !title.isEmpty())\n    && ((rpcMethod != null && !rpcMethod.isEmpty()) || (url != null && !url.isEmpty()));\nif (!ready) throw new IllegalStateException(\"CardAction needs a title and a jsonRpcMethodName or url\");","typeGuard":"boolean hasActionTarget(CardAction a) {\n    return a != null && a.getActionReference() != null && !a.getActionReference().isEmpty();\n}","tryCatchPattern":"try {\n    return builder.build();\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"jsonRpcMethodName() or url()\")) {\n        log.warn(\"CardAction built without target, skipping\");\n        return null;\n    }\n    throw e;\n}","preventionTips":["Always pair title(...) with exactly one of jsonRpcMethodName(...) or url(...)","Verify JSON-RPC method names exist in your Dev UI JSON-RPC classes","Skip creating the action when no target is available rather than building an empty one","Add tests that build all extension card actions at deployment time"],"tags":["devui","card-action","validation","jsonrpc"],"backgroundTag":"missing-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}