Skip to content

Conversation

rossigee
Copy link

Allow resourceLibvirtDomainRead to handle both UUID and domain name IDs. This fixes crashes when domains are imported by name instead of UUID.

When a domain is imported using terraform import with a domain name, the resource ID is set to the domain name. However, the read function was always trying to parse the ID as a UUID, which caused panics.

This change falls back to DomainLookupByName if UUID parsing fails and maintains backward compatibility.

rossigee added 2 commits July 11, 2025 08:06
Allow resourceLibvirtDomainRead to handle both UUID and domain name IDs.
This fixes crashes when domains are imported by name instead of UUID.

When a domain is imported using terraform import with a domain name
(e.g., 'docker-engine-1'), the resource ID is set to the domain name.
However, the read function was always trying to parse the ID as a UUID
and call DomainLookupByUUID, which caused a panic for non-UUID strings.

This change:
- First attempts to parse the ID as a UUID
- Falls back to DomainLookupByName if UUID parsing fails
- Updates the resource ID to use the UUID for consistency
- Maintains backward compatibility with existing UUID-based IDs

Fixes issues where 'terraform import' with domain names would cause
provider crashes during subsequent read operations.
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.

1 participant