Skip to content

fix: surface Proxmox error body instead of opaque status code#16

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feat/surface-proxmox-error-body
Jun 14, 2026
Merged

fix: surface Proxmox error body instead of opaque status code#16
ChrisonSimtian merged 1 commit into
mainfrom
feat/surface-proxmox-error-body

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Problem

The VM write path's SendFormAsync called Kiota's SendPrimitiveAsync(..., errorMapping: null), so any Proxmox 4xx/5xx threw a bare:

The server returned an unexpected status code and no error factory is registered for this code: 500

This discarded Proxmox's actual error message — e.g. only root can set hostpciN config for non-mapped devices — leaving callers with an opaque status code and no idea what actually went wrong.

Fix

Register a catch-all error mapping (4XX/5XX) that deserializes the error body into a new internal ProxmoxApiError : ApiException, IAdditionalDataHolder, IParsable. The type declares no fields (empty GetFieldDeserializers), so every JSON field Proxmox returns (data / errors / message) lands in AdditionalData.

On failure we now catch ProxmoxApiError and rethrow an InvalidOperationException that includes the HTTP status code and every field Proxmox returned.

Before / After

  • Before: no error factory is registered for this code: 500
  • After: Proxmox POST .../config failed (HTTP 500): errors=...; message=only root can set hostpciN config for non-mapped devices

Risk

Additive and low-risk: only the error path changes. The success path is unchanged. dotnet build -c Release is clean (0 warnings) and dotnet test -c Release passes (35/35).

🤖 Generated with Claude Code

The VM write path's SendFormAsync called Kiota's SendPrimitiveAsync with
errorMapping: null, so any Proxmox 4xx/5xx threw a bare "no error factory
is registered for this code: 500" and discarded Proxmox's actual message
(e.g. "only root can set hostpciN config for non-mapped devices").

Register a catch-all 4XX/5XX error mapping that deserializes the error body
into a new internal ProxmoxApiError (ApiException + IAdditionalDataHolder +
IParsable, no declared fields so every returned field lands in AdditionalData),
then rethrow an InvalidOperationException including the HTTP status code and
every field Proxmox returned. Only the error path changes; the success path
is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisonSimtian
ChrisonSimtian merged commit a10da30 into main Jun 14, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feat/surface-proxmox-error-body branch June 14, 2026 08:15
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