{"record":{"id":"b10965b839bf9b5b","repo":"paascloud/paascloud-master","slug":"error-b10965","errorCode":null,"errorMessage":"参数异常, 请检查参数","messagePattern":"参数异常, 请检查参数","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptAttachmentServiceImpl.java","lineNumber":204,"sourceCode":"\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Rpc get file url string.\n\t *\n\t * @param optGetUrlRequest the opt get url request\n\t *\n\t * @return the string\n\t */\n\t@Override\n\tpublic String rpcGetFileUrl(OptGetUrlRequest optGetUrlRequest) {\n\t\tLong attachmentId = optGetUrlRequest.getAttachmentId();\n\t\tLong expires = optGetUrlRequest.getExpires();\n\t\tboolean encrypt = optGetUrlRequest.isEncrypt();\n\t\tif (null == attachmentId) {\n\t\t\tthrow new IllegalArgumentException(\"参数异常, 请检查参数\");\n\t\t}\n\n\t\tOptAttachment optAttachment = this.getById(attachmentId);\n\t\tString fileName = optAttachment.getPath() + optAttachment.getName();\n\n\t\treturn getUrl(expires, encrypt, fileName);\n\t}\n\n\tprivate String getUrl(final Long expires, final boolean encrypt, final String fileName) {\n\t\tfinal String domainOfBucket;\n\t\tif (encrypt) {\n\t\t\tdomainOfBucket = paascloudProperties.getQiniu().getOss().getPrivateHost();\n\t\t\treturn optOssService.getFileUrl(domainOfBucket, fileName, expires);\n\t\t} else {\n\t\t\tdomainOfBucket = paascloudProperties.getQiniu().getOss().getPublicHost();\n\t\t\treturn domainOfBucket + \"/\" + fileName;\n\t\t}\n\t}","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptAttachmentServiceImpl.java#L186-L222","documentation":"IllegalArgumentException(\"参数异常, 请检查参数\") thrown by OptAttachmentServiceImpl.rpcGetFileUrl when the incoming OptGetUrlRequest has a null attachmentId. A null id cannot be used to look up the attachment record whose path/name is needed to build the (possibly signed, expiring) file URL.","triggerScenarios":"RPC caller invokes rpcGetFileUrl with an OptGetUrlRequest whose attachmentId was never set; client-side serialization dropped the field; caller confused attachmentId with another id field (e.g. fileId or busiId).","commonSituations":"Frontend sends an unsaved/uploading attachment (no id yet) and asks for its URL; API contract change made attachmentId optional on the client; mapper maps the wrong source field into attachmentId.","solutions":["Ensure callers set attachmentId before building OptGetUrlRequest and calling rpcGetFileUrl","Validate on the client/RPC boundary before invoking the service","Check that the field name and serialization mapping for attachmentId match between client and server","If the record may not exist either, also guard the getById result (see OPC10040008)"],"exampleFix":"// before\nOptGetUrlRequest req = new OptGetUrlRequest();\nreq.setExpires(3600L);\nString url = optAttachmentService.rpcGetFileUrl(req);\n// after\nOptGetUrlRequest req = new OptGetUrlRequest();\nPreconditions.checkArgument(attachmentId != null, \"attachmentId is required\");\nreq.setAttachmentId(attachmentId);\nreq.setExpires(3600L);\nString url = optAttachmentService.rpcGetFileUrl(req);","handlingStrategy":"validation","validationCode":"if (optGetUrlRequest == null || optGetUrlRequest.getAttachmentId() == null) {\n    throw new IllegalArgumentException(\"attachmentId is required before rpcGetFileUrl\");\n}","typeGuard":"boolean validRequest(OptGetUrlRequest r) {\n    return r != null && r.getAttachmentId() != null;\n}","tryCatchPattern":"try { url = service.rpcGetFileUrl(req); } catch (IllegalArgumentException e) { log.error(\"rpcGetFileUrl rejected: {}\", e.getMessage()); }","preventionTips":["Only request URLs for attachments that completed upload and received an id","Validate request DTOs at the RPC client boundary","Map the correct id field when building OptGetUrlRequest","Document attachmentId as required in the API contract"],"tags":["rpc","validation","null-argument"],"backgroundTag":"null-argument","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}