Skip to content

Commit 39fcbe9

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
varlink: add an operation not ready error
Add a new more catch-all error type to the varlink interface definition and code. In particular this error should be used by a scope when it can't perform an operation and needs to return something sensible to the client rather than just blowing up. Signed-off-by: John Mulligan <[email protected]>
1 parent 4a5d0c3 commit 39fcbe9

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

sambacc/varlink/interfaces/org.samba.containers.keybridge.varlink

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,16 @@ error ReadOnlyScope (name: string)
7474
# OperationNotSupported may be returned if an entry method is not supported by
7575
# the given scope.
7676
error OperationNotSupported (op: string, name: string, scope: string)
77+
78+
79+
# OperationFailed may be returned if an entry method is not currently
80+
# functioning for the given scope. This could indicate the need to retry the
81+
# operation later. It may provide a scope specific status and message for the
82+
# reason the operation is not ready.
83+
error OperationFailed (
84+
op: string,
85+
name: string,
86+
scope: string,
87+
status: ?string,
88+
reason: ?string
89+
)

sambacc/varlink/keybridge.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ class OperationNotSupported(KeyBridgeError):
100100
_expect = {"op", "name", "scope"}
101101

102102

103+
class OperationFailed(KeyBridgeError):
104+
"""
105+
OperationFailed may be returned if an entry method is not currently
106+
functioning for the given scope. This could indicate the need to retry the
107+
operation later. It may provide a scope specific status and message for the
108+
reason the operation is not ready.
109+
110+
The status value, if provided, should be a short string suitable for
111+
logging or parsing and creating conditional logic, but is scope-specific.
112+
The reason value, if provided, is a human-readable description of the
113+
problem.
114+
"""
115+
116+
_name = "OperationFailed"
117+
_expect = {"op", "name", "scope"}
118+
_optional = {"status", "reason"}
119+
120+
103121
class OpKind(str, enum.Enum):
104122
GET = "Get"
105123
SET = "Set"

0 commit comments

Comments
 (0)