fix: surface Proxmox error body instead of opaque status code#16
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The VM write path's
SendFormAsynccalled Kiota'sSendPrimitiveAsync(..., errorMapping: null), so any Proxmox 4xx/5xx threw a bare: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 internalProxmoxApiError : ApiException, IAdditionalDataHolder, IParsable. The type declares no fields (emptyGetFieldDeserializers), so every JSON field Proxmox returns (data/errors/message) lands inAdditionalData.On failure we now catch
ProxmoxApiErrorand rethrow anInvalidOperationExceptionthat includes the HTTP status code and every field Proxmox returned.Before / After
no error factory is registered for this code: 500Proxmox POST .../config failed (HTTP 500): errors=...; message=only root can set hostpciN config for non-mapped devicesRisk
Additive and low-risk: only the error path changes. The success path is unchanged.
dotnet build -c Releaseis clean (0 warnings) anddotnet test -c Releasepasses (35/35).🤖 Generated with Claude Code