{"record":{"id":"5194a40f83300fca","repo":"apache/shenyu","slug":"dynamic-result-getmessage-from-configsservice-configsexport-5194a4","errorCode":null,"errorMessage":"dynamic: result.getMessage() from configsService.configsExport(namespace)","messagePattern":"dynamic: result\\.getMessage\\(\\) from configsService\\.configsExport\\(namespace\\)","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigsExportImportController.java","lineNumber":99,"sourceCode":"        String fileName = generateFileName();\n        response.setHeader(\"Access-Control-Expose-Headers\", \"Content-Disposition\");\n        headers.add(\"Content-Disposition\", \"attachment;filename=\" + fileName);\n        return new ResponseEntity<>((byte[]) result.getData(), headers, HttpStatus.OK);\n    }\n\n    /**\n     * Export all configs.\n     *\n     * @param namespace namespaceId\n     * @param response response\n     * @return the shenyu result\n     */\n    @GetMapping(\"/exportByNamespace\")\n    @RequiresPermissions(\"system:manager:exportConfig\")\n    public ResponseEntity<byte[]> exportConfigsByNamespace(final String namespace, final HttpServletResponse response) {\n        ShenyuAdminResult result = configsService.configsExport(namespace);\n        if (!Objects.equals(CommonErrorCode.SUCCESSFUL, result.getCode())) {\n            throw new ShenyuException(result.getMessage());\n        }\n        HttpHeaders headers = new HttpHeaders();\n        String fileName = generateFileName(namespace);\n        response.setHeader(\"Access-Control-Expose-Headers\", \"Content-Disposition\");\n        headers.add(\"Content-Disposition\", \"attachment;filename=\" + fileName);\n        return new ResponseEntity<>((byte[]) result.getData(), headers, HttpStatus.OK);\n    }\n\n    /**\n     * generate export file name.\n     *\n     * @return fileName\n     */\n    private String generateFileName() {\n        return ExportImportConstants.EXPORT_CONFIG_FILE_NAME + DateFormatUtils.format(new Date(), ExportImportConstants.EXPORT_CONFIG_FILE_NAME_DATE_FORMAT)\n                + ExportImportConstants.EXPORT_CONFIG_FILE_NAME_EXT;\n    }\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigsExportImportController.java#L81-L117","documentation":"Namespace-scoped variant of the export endpoint: /configs/exportByNamespace calls configsService.configsExport(namespace) and throws ShenyuException(result.getMessage()) whenever the service returns a non-success code. The thrown message is whatever the service reported for that namespace.","triggerScenarios":"GET /configs/exportByNamespace?namespace=... with 'system:manager:exportConfig' permission while the namespace-scoped export service fails (unknown namespace, DB error, or failed data assembly for that namespace).","commonSituations":"Exporting a namespace id that has no configuration or does not exist; transient database issues during export; API scripts automating per-namespace backups.","solutions":["Verify the namespace parameter matches an existing namespace in admin","Inspect the dynamic result.getMessage()/admin logs for the root cause and fix the underlying export failure","Retry the export once the namespace data is consistent"],"exampleFix":"// before\nGET /configs/exportByNamespace?namespace=ns-xyz   // ns-xyz has no data / fails\n// after\nGET /configs/exportByNamespace?namespaceId=<registered-namespace-id>","handlingStrategy":"try-catch","validationCode":"ShenyuAdminResult ns = adminClient.get(\"/namespace/detail?id=\" + namespace);\nif (ns.getCode() != 200) { throw new IllegalStateException(\"namespace does not exist: \" + namespace); }","typeGuard":null,"tryCatchPattern":"try {\n    byte[] data = exportConfigsByNamespace(namespace);\n} catch (ShenyuException e) {\n    log.error(\"namespace export failed for {}: {}\", namespace, e.getMessage());\n}","preventionTips":["Validate the namespace exists before exporting it","Automate namespace backups only for ids registered in admin","Watch admin logs for per-namespace export failures"],"tags":["export","namespace","controller"],"backgroundTag":"api-error-response","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"}