Skip to content

Commit d8eea82

Browse files
committed
fix(humanitix): drop result/statusCode/error/message from output schemas
Errors now flow through ActionError, so the boolean 'result' flag and the 'statusCode'/'error'/'message' error fields are dead weight in output schemas. Removes them from config.json and from the data dictionaries built by fetch_single_resource and build_paginated_result in helpers.py. Drops the corresponding 'assert data["result"] is True' lines from the unit tests. Brings humanitix in line with PR #280 (supadata), PR #289 (google-sheets), and PR #307 (coda).
1 parent e299f33 commit d8eea82

3 files changed

Lines changed: 8 additions & 129 deletions

File tree

humanitix/config.json

Lines changed: 7 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,6 @@
5252
"output_schema": {
5353
"type": "object",
5454
"properties": {
55-
"result": {
56-
"type": "boolean",
57-
"description": "Whether the request was successful"
58-
},
59-
"statusCode": {
60-
"type": "integer",
61-
"description": "HTTP status code on error (e.g. 400, 401, 500)"
62-
},
63-
"error": {
64-
"type": "string",
65-
"description": "Error type on failure (e.g. 'Bad Request', 'Unauthorized')"
66-
},
67-
"message": {
68-
"type": "string",
69-
"description": "Detailed error message on failure"
70-
},
7155
"total": {
7256
"type": "integer",
7357
"description": "Total number of events matching the query"
@@ -91,10 +75,7 @@
9175
"type": "object"
9276
}
9377
}
94-
},
95-
"required": [
96-
"result"
97-
]
78+
}
9879
}
9980
},
10081
"get_orders": {
@@ -139,22 +120,6 @@
139120
"output_schema": {
140121
"type": "object",
141122
"properties": {
142-
"result": {
143-
"type": "boolean",
144-
"description": "Whether the request was successful"
145-
},
146-
"statusCode": {
147-
"type": "integer",
148-
"description": "HTTP status code on error (e.g. 401, 404, 500)"
149-
},
150-
"error": {
151-
"type": "string",
152-
"description": "Error type on failure (e.g. 'Unauthorized', 'Not Found')"
153-
},
154-
"message": {
155-
"type": "string",
156-
"description": "Detailed error message on failure"
157-
},
158123
"total": {
159124
"type": "integer",
160125
"description": "Total number of orders matching the query"
@@ -178,10 +143,7 @@
178143
"type": "object"
179144
}
180145
}
181-
},
182-
"required": [
183-
"result"
184-
]
146+
}
185147
}
186148
},
187149
"get_tickets": {
@@ -230,22 +192,6 @@
230192
"output_schema": {
231193
"type": "object",
232194
"properties": {
233-
"result": {
234-
"type": "boolean",
235-
"description": "Whether the request was successful"
236-
},
237-
"statusCode": {
238-
"type": "integer",
239-
"description": "HTTP status code on error (e.g. 401, 404)"
240-
},
241-
"error": {
242-
"type": "string",
243-
"description": "Error type on failure (e.g. 'Unauthorized', 'Not Found')"
244-
},
245-
"message": {
246-
"type": "string",
247-
"description": "Detailed error message on failure"
248-
},
249195
"total": {
250196
"type": "integer",
251197
"description": "Total number of tickets matching the query"
@@ -269,10 +215,7 @@
269215
"type": "object"
270216
}
271217
}
272-
},
273-
"required": [
274-
"result"
275-
]
218+
}
276219
}
277220
},
278221
"get_tags": {
@@ -299,22 +242,6 @@
299242
"output_schema": {
300243
"type": "object",
301244
"properties": {
302-
"result": {
303-
"type": "boolean",
304-
"description": "Whether the request was successful"
305-
},
306-
"statusCode": {
307-
"type": "integer",
308-
"description": "HTTP status code on error (e.g. 401, 404)"
309-
},
310-
"error": {
311-
"type": "string",
312-
"description": "Error type on failure (e.g. 'Unauthorized', 'Not Found')"
313-
},
314-
"message": {
315-
"type": "string",
316-
"description": "Detailed error message on failure"
317-
},
318245
"total": {
319246
"type": "integer",
320247
"description": "Total number of tags matching the query"
@@ -338,10 +265,7 @@
338265
"type": "object"
339266
}
340267
}
341-
},
342-
"required": [
343-
"result"
344-
]
268+
}
345269
}
346270
},
347271
"check_in": {
@@ -371,22 +295,6 @@
371295
"output_schema": {
372296
"type": "object",
373297
"properties": {
374-
"result": {
375-
"type": "boolean",
376-
"description": "Whether the request was successful"
377-
},
378-
"statusCode": {
379-
"type": "integer",
380-
"description": "HTTP status code on error (e.g. 400, 401)"
381-
},
382-
"error": {
383-
"type": "string",
384-
"description": "Error type on failure (e.g. 'Bad Request', 'Unauthorized')"
385-
},
386-
"message": {
387-
"type": "string",
388-
"description": "Detailed error message on failure"
389-
},
390298
"scanningMessages": {
391299
"type": "array",
392300
"description": "Scanning messages configured for the ticket",
@@ -404,10 +312,7 @@
404312
}
405313
}
406314
}
407-
},
408-
"required": [
409-
"result"
410-
]
315+
}
411316
}
412317
},
413318
"check_out": {
@@ -437,22 +342,6 @@
437342
"output_schema": {
438343
"type": "object",
439344
"properties": {
440-
"result": {
441-
"type": "boolean",
442-
"description": "Whether the request was successful"
443-
},
444-
"statusCode": {
445-
"type": "integer",
446-
"description": "HTTP status code on error (e.g. 400, 401)"
447-
},
448-
"error": {
449-
"type": "string",
450-
"description": "Error type on failure (e.g. 'Bad Request', 'Unauthorized')"
451-
},
452-
"message": {
453-
"type": "string",
454-
"description": "Detailed error message on failure"
455-
},
456345
"scanningMessages": {
457346
"type": "array",
458347
"description": "Scanning messages configured for the ticket",
@@ -470,11 +359,8 @@
470359
}
471360
}
472361
}
473-
},
474-
"required": [
475-
"result"
476-
]
362+
}
477363
}
478364
}
479365
}
480-
}
366+
}

humanitix/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ async def fetch_single_resource(
3737
data.get("message", f"HTTP {response.status}") if isinstance(data, dict) else f"HTTP {response.status}"
3838
)
3939
return ActionError(message=message)
40-
return ActionResult(data={"result": True, result_key: response.data}, cost_usd=0.0)
40+
return ActionResult(data={result_key: response.data}, cost_usd=0.0)
4141

4242

4343
def build_paginated_result(response, key: str, page: int, page_size: int | None = None) -> ActionResult:
4444
data = response.data if hasattr(response, "data") else response
4545
items = data.get(key, []) if isinstance(data, dict) else []
4646
return ActionResult(
4747
data={
48-
"result": True,
4948
key: items,
5049
"total": data.get("total", len(items)) if isinstance(data, dict) else len(items),
5150
"page": data.get("page", page) if isinstance(data, dict) else page,

humanitix/tests/test_humanitix_unit.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ async def test_list_events(self, mock_context):
4545

4646
assert result.type == ResultType.ACTION
4747
data = result.result.data
48-
assert data["result"] is True
4948
assert len(data["events"]) == 1
5049
assert data["events"][0]["_id"] == "evt_001"
5150
assert data["total"] == 1
@@ -66,7 +65,6 @@ async def test_single_event_by_id(self, mock_context):
6665

6766
assert result.type == ResultType.ACTION
6867
data = result.result.data
69-
assert data["result"] is True
7068
assert data["event"]["_id"] == "evt_001"
7169
call_url = mock_context.fetch.call_args.args[0]
7270
assert "events/evt_001" in call_url
@@ -124,7 +122,6 @@ async def test_list_orders(self, mock_context):
124122

125123
assert result.type == ResultType.ACTION
126124
data = result.result.data
127-
assert data["result"] is True
128125
assert data["orders"][0]["_id"] == "ord_001"
129126

130127
async def test_list_orders_url_includes_event_id(self, mock_context):
@@ -179,7 +176,6 @@ async def test_list_tickets(self, mock_context):
179176

180177
assert result.type == ResultType.ACTION
181178
data = result.result.data
182-
assert data["result"] is True
183179
assert data["tickets"][0]["firstName"] == "Alice"
184180

185181
async def test_list_tickets_url_includes_event_id(self, mock_context):
@@ -229,7 +225,6 @@ async def test_list_tags(self, mock_context):
229225

230226
assert result.type == ResultType.ACTION
231227
data = result.result.data
232-
assert data["result"] is True
233228
assert data["tags"][0]["name"] == "Music"
234229

235230
async def test_list_tags_url(self, mock_context):
@@ -279,7 +274,6 @@ async def test_check_in_success(self, mock_context):
279274

280275
assert result.type == ResultType.ACTION
281276
data = result.result.data
282-
assert data["result"] is True
283277
assert data["scanningMessages"][0]["header"] == "Welcome"
284278

285279
async def test_check_in_url_and_method(self, mock_context):

0 commit comments

Comments
 (0)