{"record":{"id":"4b78219eaab68992","repo":"github/copilot-sdk","slug":"defaultvalue-is-not-supported-for-type-type-name","errorCode":null,"errorMessage":"defaultValue is not supported for type <type name> without a custom coercion policy","messagePattern":"defaultValue is not supported for type <type name> without a custom coercion policy","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/tool/Param.java","lineNumber":292,"sourceCode":"                return;\n            }\n            if (type == Boolean.class || type == boolean.class) {\n                if (!\"true\".equalsIgnoreCase(defaultValue) && !\"false\".equalsIgnoreCase(defaultValue)) {\n                    throw new IllegalArgumentException(\"must be 'true' or 'false'\");\n                }\n                return;\n            }\n            if (type.isEnum()) {\n                Class<? extends Enum> enumType = (Class<? extends Enum>) type;\n                Enum.valueOf(enumType, defaultValue);\n                return;\n            }\n        } catch (RuntimeException ex) {\n            throw new IllegalArgumentException(\n                    \"defaultValue '\" + defaultValue + \"' is not valid for type \" + type.getSimpleName(), ex);\n        }\n\n        throw new IllegalArgumentException(\n                \"defaultValue is not supported for type \" + type.getName() + \" without a custom coercion policy\");\n    }\n}\n","sourceCodeStart":274,"sourceCodeEnd":296,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/tool/Param.java#L274-L296","documentation":"After built-in type checks, validateDefaultValue() reaches a fall-through that rejects defaultValue entirely for types the SDK does not know how to coerce (e.g. arbitrary objects, collections, primitives without a registered policy). The library throws instead of silently producing a mistyped default.","triggerScenarios":"Constructing a Param whose type is not one of the built-in supported coercion types (and not an enum handled above), while supplying a non-null defaultValue.","commonSituations":"Adding a new custom/complex parameter type to a tool and copying the defaultValue pattern from simpler params; upgrading the SDK where a previously coerced type lost built-in support; wrapping types in generics the validator does not recognize.","solutions":["Remove defaultValue from the Param and resolve the default in the tool handler instead","Register or implement a custom coercion policy for the type and pass it to the Param","Change the parameter type to one of the built-in supported coercion types"],"exampleFix":"// before\nnew Param(\"filter\", FilterExpr.class, \"status=open\");\n// after\nnew Param(\"filter\", FilterExpr.class, null); // default handled in handler","handlingStrategy":"validation","validationCode":"if (defaultValue != null && !isSupportedCoercionType(type)) { throw new IllegalStateException(type + \" params cannot declare defaultValue; handle default in handler\"); }","typeGuard":null,"tryCatchPattern":"try { new Param(\"filter\", FilterExpr.class, raw); } catch (IllegalArgumentException ex) { log.error(\"defaultValue unsupported for this type\", ex); return paramWithoutDefault(); }","preventionTips":["Only set defaultValue for types the SDK documents as coercible","Handle defaults inside the tool handler for custom types","Recheck supported types after SDK upgrades"],"tags":["java","validation","types"],"backgroundTag":"invalid-argument-value","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}