{"record":{"id":"158df7f8444a85bd","repo":"OpenFeign/feign","slug":"this-form-encoder-has-no-delegate-encoder-so-it-c","errorCode":null,"errorMessage":"This form encoder has no delegate encoder, so it can only encode form and multipart requests, and ${bodyType} is neither. Register an encoder that handles it.","messagePattern":"This form encoder has no delegate encoder, so it can only encode form and multipart requests, and (.+?) is neither\\. Register an encoder that handles it\\.","errorType":"exception","errorClass":"EncodeException","httpStatus":null,"severity":"error","filePath":"form/src/main/java/feign/form/FormEncoder.java","lineNumber":56,"sourceCode":"import lombok.experimental.FieldDefaults;\nimport lombok.val;\n\n/**\n * A Feign's form encoder.\n *\n * @author Artem Labazin\n */\n@FieldDefaults(level = PRIVATE, makeFinal = true)\npublic class FormEncoder implements Encoder {\n\n  private static final String CONTENT_TYPE_HEADER;\n\n  private static final Pattern CHARSET_PATTERN;\n\n  /** Stands in for a delegate that was never supplied, see {@link #FormEncoder(Encoder)}. */\n  private static final Encoder NO_DELEGATE =\n      (object, bodyType, template) -> {\n        throw new EncodeException(\n            \"This form encoder has no delegate encoder, so it can only encode form and multipart\"\n                + \" requests, and \"\n                + bodyType\n                + \" is neither. Register an encoder that handles it.\");\n      };\n\n  static {\n    CONTENT_TYPE_HEADER = \"Content-Type\";\n    CHARSET_PATTERN = Pattern.compile(\"(?<=charset=)([\\\\w\\\\-]+)\");\n  }\n\n  Encoder delegate;\n\n  Map<ContentType, ContentProcessor> processors;\n\n  /** Constructor with the default Feign's encoder as a delegate. */\n  public FormEncoder() {\n    this(new DefaultEncoder());","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/form/src/main/java/feign/form/FormEncoder.java#L38-L74","documentation":"FormEncoder wraps an optional delegate Encoder. Without a delegate it can only encode Map-based form and multipart bodies itself; anything else (POJOs, plain objects) is rejected with this EncodeException at encode time.","triggerScenarios":"Calling FormEncoder constructed with the no-arg constructor (NO_DELEGATE) and encoding a bodyType that is not a Map (form/multipart), e.g. a custom POJO or a String body.","commonSituations":"new FormEncoder() used for a client that also sends JSON/plain bodies; after upgrading feign-form the single-arg constructor call was dropped; encoders were reconfigured and the delegate was lost.","solutions":["Construct the encoder with a delegate: new FormEncoder(new JacksonEncoder()) (or GsonEncoder, SpringEncoder, etc.)","Ensure the delegate actually supports the failing bodyType","If only form/multipart is ever sent, wrap the body in a Map or use the supported @Form/@SpringForm annotations"],"exampleFix":"// before\nEncoder encoder = new FormEncoder();\n// after\nEncoder encoder = new FormEncoder(new JacksonEncoder());","handlingStrategy":"validation","validationCode":"Encoder encoder = new FormEncoder(new JacksonEncoder());\n// ensure bodyType is Map or supported by the delegate\nif (!(body instanceof Map) && !(delegateSupports(bodyType))) {\n  throw new IllegalArgumentException(\"unsupported body type for form encoder: \" + bodyType);\n}","typeGuard":"boolean isFormOrMultipart(Object body) {\n  return body instanceof Map;\n}","tryCatchPattern":"try {\n  client.call(payload);\n} catch (EncodeException e) {\n  if (e.getMessage().contains(\"no delegate encoder\")) {\n    throw new ConfigurationException(\"register a delegate encoder (Jackson/Gson/Spring)\");\n  }\n  throw e;\n}","preventionTips":["Always instantiate FormEncoder with a delegate encoder","Centralize Feign client configuration so encoder setup is not duplicated or dropped","Unit-test that each endpoint's body type is supported by the configured encoder chain"],"tags":["feign","encoder","configuration","form"],"backgroundTag":"missing-required-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"}