Skip to content

Emit useful errors when encountering type 'any' in HCL#21

Merged
chrisghill merged 3 commits intomainfrom
chris/bugfix/opentofu-handle-any
Jul 11, 2025
Merged

Emit useful errors when encountering type 'any' in HCL#21
chrisghill merged 3 commits intomainfrom
chris/bugfix/opentofu-handle-any

Conversation

@chrisghill
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances error reporting for HCL variables of type any (and empty types) and ensures hydration functions propagate informative errors.

  • Added explicit checks for empty and any types in variableTypeStringToCtyType, with descriptive error messages.
  • Refactored hydration helpers to return errors for unsupported/dynamic types and wrapped errors with contextual information.
  • Updated tests to assert expected error messages for both top‐level and nested any scenarios and added corresponding test fixtures.
Comments suppressed due to low confidence (2)

pkg/opentofu/tofutoschema_test.go:20

  • [nitpick] Consider adding a test case for an empty variable type to cover the new type cannot be empty error branch in variableTypeStringToCtyType.
	tests := []testData{

pkg/opentofu/tofutoschema.go:168

  • This call duplicates the hydration already performed by hydrateArraySchema. Consider removing this second invocation and rely on hydrateArraySchema to initialize sch.Items before setting UniqueItems.
	return hydrateSchemaFromNameTypeAndDefaults(sch.Items, "", ty.ElementType(), getDefaultChildren(name, defaults))

@chrisghill chrisghill merged commit d142128 into main Jul 11, 2025
2 of 3 checks passed
@chrisghill chrisghill deleted the chris/bugfix/opentofu-handle-any branch July 11, 2025 22:06
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.

2 participants