Fix panic when reading the logtail_connection data source - #130
Conversation
connectionCopyAttrs is shared between the resource and the data source, but the data-source schema has no `password` attribute. d.Get returns an untyped nil for an attribute the schema does not declare, so the `.(string)` assertion panicked on every successful data-source read. Skip attributes missing from the schema instead: a declared attribute always yields at least its zero value, so a nil means "not in this schema". Adds a data-source test, which reproduces the panic without the fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Follow-up: #131 is stacked on this branch and proposes the structural fix. This PR stops the panic where it happens: the copier skips attributes the schema If you'd rather take the structural change directly, this PR can be closed in favour |
528d69d to
8e7028f
Compare
|
Hi @prochac, Thanks for the Terraform fixes, and for sharing the https://github.com/prochac/betterstack-logs-client-go library - really appreciate it π It was nice to talk to you, and thanks for all the energy π |
Feel free to fork it. I chose ISC to fit your ecosystem. |
Closes #129.
connectionCopyAttrsis shared between thelogtail_connectionresource and the data source, but the data-source schema declares nopasswordattribute.d.Getreturns an untypednilfor an attribute the schema does not declare, so the.(string)assertion panicked on every successful data-source read, in every version since the data source was added, through10.17.0.The fix skips attributes that are missing from the schema: a declared attribute always yields at least its zero value, so a
nilmeans "not in this schema".Adds
internal/provider/data_connection_test.go, which reproduces the panic without the fix.π€ Generated with Claude Code