mirror of
https://github.com/luthermonson/go-proxmox.git
synced 2026-04-26 01:15:57 +03:00
[GH-ISSUE #199] Zero values of configuration structs overwrite PVE API defaults #55
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/go-proxmox#55
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xortim on GitHub (Jun 10, 2025).
Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/199
The zero values of all PVE configuration structs are overwriting the default values defined by the PVE API. This can lead to unexpected behavior for consumers who instantiate configuration structs without explicitly setting every field.
For example, in
ContainerConfig, theConsolefield is defined as anIntOrBool, which defaults to0(false) in Go. However, according to the PVE API documentation, the expected default is1(true). This discrepancy means that if a consumer leavesConsoleunset, the resulting API call may disable the console even though it was not their intent.This pattern occurs in multiple configuration structs throughout the codebase.
Expected behavior
If a field is not explicitly set by the consumer, the Proxmox API's default value should be preserved, not overwritten by Go's zero value.
Potential solution
Introduce pointer types for configuration fields where the PVE API has meaningful defaults. This allows
omitemptyto work correctly and avoids sending unintended zero values in API requests.Additional context
This affects both usability and correctness, especially when consumers rely on the API to apply its documented defaults.