Skip to content

Commit 06f8b9b

Browse files
committed
feat(api): include error field in StatInstancePath response
Add error field to PathInfo schema in OpenAPI spec and update handler to propagate error messages from the guest agent (e.g., permission denied). This allows clients to distinguish between 'path does not exist' and 'cannot access path due to error'.
1 parent 719ef66 commit 06f8b9b

File tree

3 files changed

+120
-106
lines changed

3 files changed

+120
-106
lines changed

cmd/api/api/instances.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,20 @@ func (s *ApiService) StatInstancePath(ctx context.Context, request oapi.StatInst
482482

483483
// Convert types from protobuf to OAPI
484484
mode := int(resp.Mode)
485-
return oapi.StatInstancePath200JSONResponse{
485+
response := oapi.StatInstancePath200JSONResponse{
486486
Exists: resp.Exists,
487487
IsDir: &resp.IsDir,
488488
IsFile: &resp.IsFile,
489489
IsSymlink: &resp.IsSymlink,
490490
LinkTarget: &resp.LinkTarget,
491491
Mode: &mode,
492492
Size: &resp.Size,
493-
}, nil
493+
}
494+
// Include error message if stat failed (e.g., permission denied)
495+
if resp.Error != "" {
496+
response.Error = &resp.Error
497+
}
498+
return response, nil
494499
}
495500

496501
// AttachVolume attaches a volume to an instance (not yet implemented)

lib/oapi/oapi.go

Lines changed: 108 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ components:
289289
format: int64
290290
description: File size in bytes
291291
example: 1024
292+
error:
293+
type: string
294+
description: Error message if stat failed (e.g., permission denied). Only set when exists is false due to an error rather than the path not existing.
295+
nullable: true
296+
example: "permission denied"
292297

293298
CreateImageRequest:
294299
type: object

0 commit comments

Comments
 (0)