github/copilot-sdk · error · IllegalArgumentException

defaultValue is not supported for type

Error message

defaultValue is not supported for type <type name> without a custom coercion policy

What it means

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.

Solutions

  1. Remove defaultValue from the Param and resolve the default in the tool handler instead
  2. Register or implement a custom coercion policy for the type and pass it to the Param
  3. Change the parameter type to one of the built-in supported coercion types

Example fix

// before
new Param("filter", FilterExpr.class, "status=open");
// after
new Param("filter", FilterExpr.class, null); // default handled in handler
Defensive patterns

Strategy: validation

Validate before calling

if (defaultValue != null && !isSupportedCoercionType(type)) { throw new IllegalStateException(type + " params cannot declare defaultValue; handle default in handler"); }

Try / catch

try { new Param("filter", FilterExpr.class, raw); } catch (IllegalArgumentException ex) { log.error("defaultValue unsupported for this type", ex); return paramWithoutDefault(); }

Prevention

When it happens

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

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

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/4b78219eaab68992. Report an issue: GitHub.

Appendix: source

Thrown at java/sdk/src/main/java/com/github/copilot/tool/Param.java:292

                return;
            }
            if (type == Boolean.class || type == boolean.class) {
                if (!"true".equalsIgnoreCase(defaultValue) && !"false".equalsIgnoreCase(defaultValue)) {
                    throw new IllegalArgumentException("must be 'true' or 'false'");
                }
                return;
            }
            if (type.isEnum()) {
                Class<? extends Enum> enumType = (Class<? extends Enum>) type;
                Enum.valueOf(enumType, defaultValue);
                return;
            }
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException(
                    "defaultValue '" + defaultValue + "' is not valid for type " + type.getSimpleName(), ex);
        }

        throw new IllegalArgumentException(
                "defaultValue is not supported for type " + type.getName() + " without a custom coercion policy");
    }
}

View on GitHub (pinned to cd8cf15dc3)