{"record":{"id":"14122766171786b4","repo":"apache/shenyu","slug":"webi18nexception-message-objects","errorCode":null,"errorMessage":"WebI18nException(message, objects)","messagePattern":"WebI18nException\\(message, objects\\)","errorType":"exception","errorClass":"WebI18nException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/WebI18nAssert.java","lineNumber":100,"sourceCode":"     *\n     * @param test    string\n     * @param message error message\n     * @param objects objects\n     */\n    public static void isTrue(final Boolean test, final String message, final Object... objects) {\n        if (!Boolean.TRUE.equals(test)) {\n            fail(message, objects);\n        }\n    }\n    \n    /**\n     * fail.\n     *\n     * @param message message\n     * @param objects objects\n     */\n    public static void fail(final String message, final Object... objects) {\n        throw new WebI18nException(message, objects);\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/WebI18nAssert.java#L82-L103","documentation":"WebI18nAssert.fail throws a WebI18nException carrying the message key plus optional i18n arguments. It is the assertion mechanism used across shenyu-admin for parameter/state validation, with the message resolved to the caller's locale at the API layer. Raised from isTrue and similar assert helpers.","triggerScenarios":"Any code path calling WebI18nAssert.isTrue(cond, \"key\", args...) (or related asserts) when the condition is false — e.g. missing request parameters, invalid enum values in admin REST endpoints, or business preconditions failing.","commonSituations":"Dashboard/API clients sending malformed or incomplete payloads to shenyu-admin endpoints (create/update plugin, selector, rule) and hitting a validation assert.","solutions":["Read the exception's message key and look it up in the admin i18n resource bundle to see the human-readable cause.","Fix the request payload so the asserted condition holds (fill required fields, use valid values).","In your own code, prefer pre-checking conditions instead of relying on the assert to reject them."],"exampleFix":"// before\nwebI18nAssertPayload(name, null); // fails WebI18nAssert.notBlank\n// after\n// ensure required fields present before calling the admin API\nrequest.setName(\"myPlugin\"); // all required fields populated","handlingStrategy":"validation","validationCode":"// client-side pre-check before calling admin API\nif (name == null || name.isBlank()) {\n    throw new IllegalArgumentException(\"name is required\");\n}\nWebI18nAssert.isTrue(StringUtils.isNotBlank(name), \"plugin.name.required\");","typeGuard":"static <T> T requireNonNull(T value, String i18nKey) {\n    if (value == null) { WebI18nAssert.fail(i18nKey); }\n    return value;\n}","tryCatchPattern":"try {\n    adminService.createSelector(request);\n} catch (WebI18nException e) {\n    // resolve e.getMessage() i18n key and map to a user-facing message\n    String userMessage = messageSource.getMessage(e.getMessage(), e.getObjects(), locale);\n}","preventionTips":["Resolve the message key in the admin i18n bundle to identify the exact failed assertion.","Validate payloads client-side before calling admin REST endpoints.","Keep required-field lists in sync with the dashboard forms."],"tags":["i18n","validation","assertion","admin-api"],"backgroundTag":"schema-validation-failed","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}