apache/shenyu · error · ShenyuException

dynamic: result.getMessage() from…

Error message

dynamic: result.getMessage() from configsService.configsExport(namespace)

What it means

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.

Solutions

  1. Verify the namespace parameter matches an existing namespace in admin
  2. Inspect the dynamic result.getMessage()/admin logs for the root cause and fix the underlying export failure
  3. Retry the export once the namespace data is consistent

Example fix

// before
GET /configs/exportByNamespace?namespace=ns-xyz   // ns-xyz has no data / fails
// after
GET /configs/exportByNamespace?namespaceId=<registered-namespace-id>
Defensive patterns

Strategy: try-catch

Validate before calling

ShenyuAdminResult ns = adminClient.get("/namespace/detail?id=" + namespace);
if (ns.getCode() != 200) { throw new IllegalStateException("namespace does not exist: " + namespace); }

Try / catch

try {
    byte[] data = exportConfigsByNamespace(namespace);
} catch (ShenyuException e) {
    log.error("namespace export failed for {}: {}", namespace, e.getMessage());
}

Prevention

When it happens

Trigger: 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).

Common situations: Exporting a namespace id that has no configuration or does not exist; transient database issues during export; API scripts automating per-namespace backups.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/5194a40f83300fca. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigsExportImportController.java:99

        String fileName = generateFileName();
        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
        headers.add("Content-Disposition", "attachment;filename=" + fileName);
        return new ResponseEntity<>((byte[]) result.getData(), headers, HttpStatus.OK);
    }

    /**
     * Export all configs.
     *
     * @param namespace namespaceId
     * @param response response
     * @return the shenyu result
     */
    @GetMapping("/exportByNamespace")
    @RequiresPermissions("system:manager:exportConfig")
    public ResponseEntity<byte[]> exportConfigsByNamespace(final String namespace, final HttpServletResponse response) {
        ShenyuAdminResult result = configsService.configsExport(namespace);
        if (!Objects.equals(CommonErrorCode.SUCCESSFUL, result.getCode())) {
            throw new ShenyuException(result.getMessage());
        }
        HttpHeaders headers = new HttpHeaders();
        String fileName = generateFileName(namespace);
        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
        headers.add("Content-Disposition", "attachment;filename=" + fileName);
        return new ResponseEntity<>((byte[]) result.getData(), headers, HttpStatus.OK);
    }

    /**
     * generate export file name.
     *
     * @return fileName
     */
    private String generateFileName() {
        return ExportImportConstants.EXPORT_CONFIG_FILE_NAME + DateFormatUtils.format(new Date(), ExportImportConstants.EXPORT_CONFIG_FILE_NAME_DATE_FORMAT)
                + ExportImportConstants.EXPORT_CONFIG_FILE_NAME_EXT;
    }

View on GitHub (pinned to 567142e072)