paascloud/paascloud-master · error · IllegalArgumentException

参数异常, 请检查参数

Error message

参数异常, 请检查参数

What it means

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.

Solutions

  1. Ensure callers set attachmentId before building OptGetUrlRequest and calling rpcGetFileUrl
  2. Validate on the client/RPC boundary before invoking the service
  3. Check that the field name and serialization mapping for attachmentId match between client and server
  4. If the record may not exist either, also guard the getById result (see OPC10040008)

Example fix

// before
OptGetUrlRequest req = new OptGetUrlRequest();
req.setExpires(3600L);
String url = optAttachmentService.rpcGetFileUrl(req);
// after
OptGetUrlRequest req = new OptGetUrlRequest();
Preconditions.checkArgument(attachmentId != null, "attachmentId is required");
req.setAttachmentId(attachmentId);
req.setExpires(3600L);
String url = optAttachmentService.rpcGetFileUrl(req);
Defensive patterns

Strategy: validation

Validate before calling

if (optGetUrlRequest == null || optGetUrlRequest.getAttachmentId() == null) {
    throw new IllegalArgumentException("attachmentId is required before rpcGetFileUrl");
}

Type guard

boolean validRequest(OptGetUrlRequest r) {
    return r != null && r.getAttachmentId() != null;
}

Try / catch

try { url = service.rpcGetFileUrl(req); } catch (IllegalArgumentException e) { log.error("rpcGetFileUrl rejected: {}", e.getMessage()); }

Prevention

When it happens

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

Common situations: 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.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/b10965b839bf9b5b. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptAttachmentServiceImpl.java:204

			}
		}
		return null;
	}

	/**
	 * Rpc get file url string.
	 *
	 * @param optGetUrlRequest the opt get url request
	 *
	 * @return the string
	 */
	@Override
	public String rpcGetFileUrl(OptGetUrlRequest optGetUrlRequest) {
		Long attachmentId = optGetUrlRequest.getAttachmentId();
		Long expires = optGetUrlRequest.getExpires();
		boolean encrypt = optGetUrlRequest.isEncrypt();
		if (null == attachmentId) {
			throw new IllegalArgumentException("参数异常, 请检查参数");
		}

		OptAttachment optAttachment = this.getById(attachmentId);
		String fileName = optAttachment.getPath() + optAttachment.getName();

		return getUrl(expires, encrypt, fileName);
	}

	private String getUrl(final Long expires, final boolean encrypt, final String fileName) {
		final String domainOfBucket;
		if (encrypt) {
			domainOfBucket = paascloudProperties.getQiniu().getOss().getPrivateHost();
			return optOssService.getFileUrl(domainOfBucket, fileName, expires);
		} else {
			domainOfBucket = paascloudProperties.getQiniu().getOss().getPublicHost();
			return domainOfBucket + "/" + fileName;
		}
	}

View on GitHub (pinned to 781281a950)