Skip to content

Fix panic when reading the logtail_connection data source - #130

Merged
paweljw merged 1 commit into
BetterStackHQ:mainfrom
prochac:fix/connection-data-source-panic
Aug 18, 2026
Merged

Fix panic when reading the logtail_connection data source#130
paweljw merged 1 commit into
BetterStackHQ:mainfrom
prochac:fix/connection-data-source-panic

Conversation

@prochac

@prochac prochac commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #129.

connectionCopyAttrs is shared between the logtail_connection resource and the data source, but the data-source schema declares 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, in every version since the data source was added, through 10.17.0.

The fix skips attributes that are missing from the schema: a declared attribute always yields at least its zero value, so a nil means "not in this schema".

Adds internal/provider/data_connection_test.go, which reproduces the panic without the fix.

πŸ€– Generated with Claude Code

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>
@prochac

prochac commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

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
doesn't declare. #131 removes the reason the mismatch existed at all, deriving the
data source schema from connectionSchema instead of hand-maintaining a second copy
that had drifted, with a test pinning the two together. It also picks up a related
bug the consolidation exposed (data_region/valid_until coming back normalized
from the API and forcing recreation on every apply).

If you'd rather take the structural change directly, this PR can be closed in favour
of #131.

@prochac
prochac force-pushed the fix/connection-data-source-panic branch from 528d69d to 8e7028f Compare August 17, 2026 11:14
@paweljw
paweljw merged commit b5d28ae into BetterStackHQ:main Aug 18, 2026
6 of 18 checks passed
@PetrHeinz

Copy link
Copy Markdown
Member

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 πŸš€

@prochac

prochac commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logtail_connection data source panics on read

3 participants