{"record":{"id":"112a83301230c857","repo":"deeplearning4j/deeplearning4j","slug":"illegal-arg-type-descriptor-argtype","errorCode":null,"errorMessage":"Illegal arg type ${descriptor.argType}","messagePattern":"Illegal arg type (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"nd4j/samediff-import/samediff-import-api/src/main/kotlin/org/nd4j/samediff/frameworkimport/rule/attribute/BaseAttributeExtractionRule.kt","lineNumber":104,"sourceCode":"\n\n    override fun serialize(): MapperNamespace.MappingRule {\n        val builder = MapperNamespace.MappingRule.newBuilder()\n        builder.ruleName = name()\n        builder.functionName = name()\n        builder.ruleType = \"attribute\"\n        builder.inputFrameworkOpName = this.inputFrameworkOpName\n        val descriptorList = opDescriptor!!.argDescriptorList\n        println(\"Serializing op ${opDescriptor!!.name}\")\n        for ((k, v) in transformerArgs) {\n            v.forEach { descriptor ->\n                when (descriptor.argType) {\n                    OpNamespace.ArgDescriptor.ArgType.STRING -> builder.addInputStringAttrName(descriptor.name)\n                    OpNamespace.ArgDescriptor.ArgType.BOOL -> builder.addInputBooleanName(descriptor.name)\n                    OpNamespace.ArgDescriptor.ArgType.DOUBLE, OpNamespace.ArgDescriptor.ArgType.FLOAT -> builder.addInputFloatName(descriptor.name)\n                    OpNamespace.ArgDescriptor.ArgType.INT32, OpNamespace.ArgDescriptor.ArgType.INT64 -> builder.addInputIntName(descriptor.name)\n                    OpNamespace.ArgDescriptor.ArgType.INPUT_TENSOR -> builder.addInputTensorName(descriptor.name)\n                    else -> {throw IllegalArgumentException(\"Illegal arg type ${descriptor.argType}\")}\n\n                }\n\n                builder.addTransformerArgs(MapperNamespace.TransformerArgs.newBuilder().setKey(k).addAllTransformerArgs(v))\n            }\n\n        }\n\n        /**\n         * TODO: metadata (perhaps looking up from each framework for each attribute)\n         * what each named type is.\n         */\n        mappingNamesToPerform.forEach { outputName, inputName ->\n            val descriptorForName = opDescriptor!!.argDescriptorList.first { descriptor -> descriptor.name == outputName }\n            builder.putInputToOutput(outputName,inputName)\n            when(descriptorForName.argType) {\n                OpNamespace.ArgDescriptor.ArgType.BOOL -> { builder.addOutputBooleanName(outputName)}\n                OpNamespace.ArgDescriptor.ArgType.INT64 -> {builder.addOutputIntName(outputName)}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/nd4j/samediff-import/samediff-import-api/src/main/kotlin/org/nd4j/samediff/frameworkimport/rule/attribute/BaseAttributeExtractionRule.kt#L86-L122","documentation":"BaseAttributeExtractionRule.serialize() iterates the rule's transformerArgs and maps each ArgDescriptor's argType to an input category (string attr, bool, float, int, tensor). If a transformer arg declares an argType outside that set (e.g. DOUBLE-only outputs like OUTPUT_TENSOR, DATA_TYPE, or UNRECOGNIZED), the exhaustive when falls to the else branch and throws IllegalArgumentException('Illegal arg type ...'). The library throws it because serialize() cannot classify the descriptor into the MappingRule's typed input-name lists.","triggerScenarios":"Calling serialize() on an attribute extraction rule whose transformerArgs map contains an OpNamespace.ArgDescriptor with argType not in {STRING, BOOL, DOUBLE, FLOAT, INT32, INT64, INPUT_TENSOR} — e.g. a transformer arg of type OUTPUT_TENSOR, DATA_TYPE, or a protobuf-parsed UNRECOGNIZED enum value.","commonSituations":"Hand-written or generated op mapping definitions (import config for TF/ONNX/PyTorch graphs) that list transformer args with output-tensor or data-type arg types in input position; version drift where the nd4j op descriptor file assigns a new arg type to a named arg used as a transformer arg; copy-pasting an output descriptor into transformerArgs.","solutions":["Inspect the rule's transformerArgs and change the offending descriptor's argType to one supported here (STRING, BOOL, DOUBLE, FLOAT, INT32, INT64, or INPUT_TENSOR)","Move the offending descriptor out of transformerArgs — output-tensor/data-type descriptors belong in output mapping, not as transformer args","Regenerate the op descriptor (nd4j ops .proto) so the named arg has the expected input arg type","Patch serialize()'s when to handle the missing ArgType if it is legitimately needed"],"exampleFix":"// before\ntransformerArgs = mapOf(\"axis\" to listOf(ArgDescriptor { name=\"axis\"; argType = ArgType.OUTPUT_TENSOR }))\n// after\ntransformerArgs = mapOf(\"axis\" to listOf(ArgDescriptor { name=\"axis\"; argType = ArgType.INT64 }))","handlingStrategy":"validation","validationCode":"val allowed = setOf(ArgType.STRING, ArgType.BOOL, ArgType.DOUBLE, ArgType.FLOAT, ArgType.INT32, ArgType.INT64, ArgType.INPUT_TENSOR)\nrequire(rule.transformerArgs().values.flatten().all { it.argType in allowed }) { \"transformer arg ${it.name} has unsupported argType ${it.argType}\" }","typeGuard":"fun isSerializableInputArgType(t: OpNamespace.ArgDescriptor.ArgType) = t in setOf(\n    ArgType.STRING, ArgType.BOOL, ArgType.DOUBLE, ArgType.FLOAT,\n    ArgType.INT32, ArgType.INT64, ArgType.INPUT_TENSOR)","tryCatchPattern":"try { rule.serialize() } catch (e: IllegalArgumentException) { if (!e.message!!.startsWith(\"Illegal arg type\")) throw e; log.error(\"Fix transformerArgs argType: ${e.message}\") }","preventionTips":["Declare transformer args only with input-position arg types (STRING/BOOL/numeric/INPUT_TENSOR)","Never reuse output descriptors (OUTPUT_TENSOR, DATA_TYPE) as transformer args","Validate mapping definitions at load time before running import","Regenerate op descriptors when bumping nd4j versions and re-run validation"],"tags":["kotlin","protobuf","enum","import"],"backgroundTag":"invalid-enum-value","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}