{"record":{"id":"df3b396fda794d3b","repo":"OpenFeign/feign","slug":"values-are-required-df3b39","errorCode":null,"errorMessage":"values are required","messagePattern":"values are required","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/template/QueryTemplate.java","lineNumber":81,"sourceCode":"   * @param name of the query parameter.\n   * @param values in the template.\n   * @param charset for the template.\n   * @param collectionFormat to use.\n   * @param decodeSlash if slash characters should be decoded\n   * @return a QueryTemplate\n   */\n  public static QueryTemplate create(\n      String name,\n      Iterable<String> values,\n      Charset charset,\n      CollectionFormat collectionFormat,\n      boolean decodeSlash) {\n    if (Util.isBlank(name)) {\n      throw new IllegalArgumentException(\"name is required.\");\n    }\n\n    if (values == null) {\n      throw new IllegalArgumentException(\"values are required\");\n    }\n\n    /* remove all empty values from the array */\n    Collection<String> remaining =\n        StreamSupport.stream(values.spliterator(), false)\n            .filter(Util::isNotBlank)\n            .collect(Collectors.toList());\n\n    return new QueryTemplate(name, remaining, charset, collectionFormat, decodeSlash);\n  }\n\n  /**\n   * Append a value to the Query Template.\n   *\n   * @param queryTemplate to append to.\n   * @param values to append.\n   * @return a new QueryTemplate with value appended.\n   */","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/template/QueryTemplate.java#L63-L99","documentation":"QueryTemplate.create() also validates the values parameter, throwing IllegalArgumentException('values are required') when it is null. A query template with no value collection at all cannot be constructed (blank individual values are filtered later, but the collection itself must exist).","triggerScenarios":"Calling QueryTemplate.create(name, null, charset, collectionFormat, decodeSlash), or RequestTemplate.query(name, (Iterable) null) / append() with a null values iterable — often from a map lookup that returned null instead of an empty collection.","commonSituations":"Passing params.get(key) (null when key absent) directly into query(); custom Contract code assembling query parameters from nullable lists; interceptor code adding query params from optional configuration.","solutions":["Substitute an empty collection (Collections.emptyList()) when the values source is null, so the template is still created and blank values are filtered naturally.","Guard the call site: skip calling query()/create() when the value list is null.","Catch IllegalArgumentException at a boundary that processes untrusted parameter maps and log/skip the offending parameter."],"exampleFix":"// before\nrequestTemplate.query(name, params.get(name)); // null when key missing\n// after\nList<String> values = params.getOrDefault(name, Collections.emptyList());\nrequestTemplate.query(name, values);","handlingStrategy":"validation","validationCode":"Iterable<String> safeValues = (values == null) ? Collections.emptyList() : values;\nQueryTemplate.create(name, safeValues, charset, collectionFormat, decodeSlash);","typeGuard":"static Iterable<String> orEmpty(Iterable<String> values) {\n  return values == null ? Collections.emptyList() : values;\n}","tryCatchPattern":"try {\n  requestTemplate.query(name, values);\n} catch (IllegalArgumentException e) {\n  // values was null: default to empty collection or skip parameter\n}","preventionTips":["Use Map.getOrDefault(key, Collections.emptyList()) for query parameter lookups.","Normalize all nullable collections to empty collections in one utility used by template-building code.","Distinguish 'no values' (empty collection is fine) from 'programming bug' (null) in your own API."],"tags":["java","feign","query-string","null-argument","request-template"],"backgroundTag":"null-argument","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}