{"record":{"id":"afcaf650a7aab1d9","repo":"opentofu/opentofu","slug":"invalid-schema-none-of-configschema-attribute-req","errorCode":null,"errorMessage":"invalid schema: none of configschema.Attribute.Required/Computed/Optional set on ","messagePattern":"invalid schema: none of configschema\\.Attribute\\.Required/Computed/Optional set on ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/hcl2shim/mock_value_composer.go","lineNumber":207,"sourceCode":"\t\t\t\t// at this time there is no possible way for providers to specify NestedGroup.\n\t\t\t\tmockAttrs[k] = cty.NullVal(attr.ImpliedType())\n\t\t\t}\n\t\t} else if attr.Computed {\n\t\t\t// Value from provider only\n\t\t\tif hasConfig {\n\t\t\t\tdiags = diags.Append(tfdiags.WholeContainingBody(\n\t\t\t\t\ttfdiags.Error,\n\t\t\t\t\tfmt.Sprintf(\"Invalid mock/override field `%v`\", k),\n\t\t\t\t\t\"Config value can not be specified for computed field\",\n\t\t\t\t))\n\t\t\t}\n\t\t\tif hasOverride {\n\t\t\t\tmockAttrs[k] = ovConvert\n\t\t\t} else {\n\t\t\t\tmockAttrs[k] = mvc.getMockValueByType(attr.ImpliedType())\n\t\t\t}\n\t\t} else {\n\t\t\tpanic(\"invalid schema: none of configschema.Attribute.Required/Computed/Optional set on \" + k)\n\t\t}\n\t}\n\n\treturn mockAttrs, diags\n}\n\nfunc (mvc MockValueComposer) composeMockValueForBlocks(schema *configschema.Block, configMap map[string]cty.Value, overrides map[string]cty.Value) (map[string]cty.Value, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\n\tmockBlocks := make(map[string]cty.Value)\n\n\timpliedTypes := schema.ImpliedType().AttributeTypes()\n\n\t// Stable order is important here so random values match its fields between function calls.\n\tfor _, kv := range mapToSortedSlice(schema.BlockTypes) {\n\t\tk, block := kv.k, kv.v\n\n\t\t// Checking if the config value really present for the block.","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/configs/hcl2shim/mock_value_composer.go#L189-L225","documentation":"MockValueComposer (the engine behind tofu test mocks and overrides) requires every provider attribute to declare at least one of Required, Optional, or Computed (WriteOnly is handled earlier). If all three are false it cannot decide how to synthesize a value and panics, naming the attribute. This is a provider schema bug - your mock .tf files are not at fault.","triggerScenarios":"Running tofu test with mocks (or any plan consuming composed mock values) against a provider whose schema contains an attribute with Required=false, Optional=false, Computed=false; the if/else chain in composeMockValueForAttrs falls through to the final else.","commonSituations":"Provider schemas converted over the wire that lost the mode flags; experimental provider frameworks emitting flag-less attributes; version skew between the provider and OpenTofu's test engine.","solutions":["Pin/downgrade the provider to the previous working version and re-run tofu test","Identify the culprit attribute: tofu providers schema -json and look for attributes where required, optional and computed are all false","Report to the provider maintainer with the attribute name from the panic message","As a workaround, scope tests/mocks away from the resource or data source containing the broken attribute"],"exampleFix":"// before - provider attribute with no mode flags\n\"broken\": {Type: cty.String, Optional: false, Required: false, Computed: false}\n\n// after - declare a mode\n\"broken\": {Type: cty.String, Optional: true}","handlingStrategy":"validation","validationCode":"$ tofu providers schema -json | jq '[.. | objects | select(has(\"required\")) | select((.required // false) or (.optional // false) or (.computed // false)) | empty] // []\n# inverted check: list attributes where all three flags are false should be empty","typeGuard":"func attributeHasMode(a *configschema.Attribute) bool {\n\tif a == nil {\n\t\treturn true\n\t}\n\treturn a.Required || a.Optional || a.Computed || a.WriteOnly\n}","tryCatchPattern":null,"preventionTips":["Run tofu test against a known-good provider pin in CI","After provider upgrades, dump the schema and check for mode-less attributes","Report flag-less attributes to provider maintainers immediately"],"tags":["panic","schema","provider","testing","mocks"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}