{"record":{"id":"00dcf18068556871","repo":"airbnb/epoxy","slug":"default-attribute-has-no-default-code","errorCode":null,"errorMessage":"Default attribute has no default code","messagePattern":"Default attribute has no default code","errorType":"exception","errorClass":"EpoxyProcessorException","httpStatus":null,"severity":"error","filePath":"epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelInfo.kt","lineNumber":266,"sourceCode":"\n    class AttributeGroup internal constructor(\n        groupName: String?,\n        attributes: List<AttributeInfo>,\n        defaultAttribute: AttributeInfo?\n    ) {\n        val name: String?\n        val attributes: List<AttributeInfo>\n        val isRequired: Boolean\n        val defaultAttribute: AttributeInfo?\n\n        init {\n            if (attributes.isEmpty()) {\n                throw buildEpoxyException(\"Attributes cannot be empty\")\n            }\n            if (defaultAttribute != null && defaultAttribute.codeToSetDefault.isEmpty &&\n                !hasDefaultKotlinValue(defaultAttribute)\n            ) {\n                throw buildEpoxyException(\"Default attribute has no default code\")\n            }\n            this.defaultAttribute = defaultAttribute\n            isRequired = defaultAttribute == null\n            name = groupName\n            this.attributes =\n                ArrayList(attributes)\n        }\n    }\n\n    companion object {\n        const val RESET_METHOD = \"reset\"\n        const val GENERATED_CLASS_NAME_SUFFIX = \"_\"\n        const val GENERATED_MODEL_SUFFIX = \"Model$GENERATED_CLASS_NAME_SUFFIX\"\n\n        fun buildParamSpecs(params: List<XVariableElement>, memoizer: Memoizer): List<ParameterSpec> {\n            return params.map { it.toParameterSpec(memoizer) }\n        }\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/airbnb/epoxy/blob/e45bd3a61fe3a1f130e184f5b8dcf172ab99025a/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelInfo.kt#L248-L284","documentation":"GeneratedModelInfo.AttributeGroup requires that when a default attribute is designated, the processor can emit code to set it: either codeToSetDefault is non-empty or the attribute has a Kotlin default value (checked by hasDefaultKotlinValue). If a default attribute is set but carries no default-setting code, the processor throws 'Default attribute has no default code' to prevent generating models that cannot apply the default. Reached from addAttributeGroup.","triggerScenarios":"AttributeGroup is constructed with a non-null defaultAttribute whose codeToSetDefault is empty and which has no Kotlin default value — i.e. an attribute was marked as the group default but the processor could not derive any code to assign it.","commonSituations":"Model attributes with exotic types or custom setters that the processor cannot render default code for; attributes introduced via custom processor extensions; Kotlin/Java mixed models where default detection fails; Epoxy version upgrades changing default-code generation.","solutions":["Ensure the default attribute is one the processor can set: give it a type with straightforward setter code, or declare a Kotlin default value in the @EpoxyAttribute (e.g. `var title: String = \"\"`)\nIf the attribute should not be a default, remove it as the designated default so the group just becomes required (isRequired = true)","If you construct AttributeGroup in custom code, only pass a defaultAttribute after verifying codeToSetDefault is not empty or hasDefaultKotlinValue is true","Report/bisect against the Epoxy processor version if a plain annotated attribute triggers this"],"exampleFix":"// before\n@EpoxyAttribute var title: String? = null // designated default, but no default code generated\n// after\n@EpoxyAttribute var title: String = \"\" // Kotlin default value -> hasDefaultKotlinValue true","handlingStrategy":"validation","validationCode":"// caller-side check before designating a default\nval canBeDefault = attribute.codeToSetDefault.isNotEmpty // or attribute has Kotlin default value\nif (defaultCandidate != null && !canBeDefault) {\n    error(\"Default attribute '${defaultCandidate.name}' has no default code\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give default attributes explicit Kotlin default values (var x: T = default)","Don't mark attributes with types/setters the processor cannot render as defaults","Only designate a default attribute when its default-setting code is verifiably non-empty"],"tags":["kotlin","annotation-processor","validation","epoxy"],"backgroundTag":"missing-required-argument","analyzedSha":"e45bd3a61fe3a1f130e184f5b8dcf172ab99025a","analyzedAt":"2026-09-13T03:24:16.052Z","contentChangedAt":"2026-09-13T03:24:16.052Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}