Skip to content

Commit ebdaecc

Browse files
rmaticevicmjuraga
authored andcommitted
BUG/MINOR: spec: return the error model from every error response
Several error responses declared a body that is not the API error model: the two 429 responses used an inline {code, message} object, the stats 500 pointed at its own success model, and the text/plain endpoints (raw configuration, profiling tasks and memory) described their error body as a plain string although text/plain is only used for 2xx. Point them at predefined responses returning the error model. That needs TooManyRequests added to the global responses, shaped like the existing ones with the Configuration-Version header and the error definition. Also fix 11 single-resource GET endpoints (13 paths after parent templating) whose 404 answered with AlreadyExists instead of NotFound.
1 parent 62652a3 commit ebdaecc

16 files changed

Lines changed: 56 additions & 128 deletions

‎specification/build/haproxy_spec.yaml‎

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12558,6 +12558,14 @@ responses:
1255812558
type: string
1255912559
schema:
1256012560
$ref: '#/definitions/error'
12561+
TooManyRequests:
12562+
description: Too many open transactions
12563+
headers:
12564+
Configuration-Version:
12565+
description: Configuration file version
12566+
type: string
12567+
schema:
12568+
$ref: '#/definitions/error'
1256112569
DefaultError:
1256212570
description: General Error
1256312571
headers:
@@ -13229,9 +13237,7 @@ paths:
1322913237
schema:
1323013238
$ref: '#/definitions/native_stats'
1323113239
"500":
13232-
description: Internal Server Error
13233-
schema:
13234-
$ref: '#/definitions/native_stats'
13240+
$ref: '#/responses/DefaultError'
1323513241
default:
1323613242
$ref: '#/responses/DefaultError'
1323713243
summary: Gets stats
@@ -13283,17 +13289,7 @@ paths:
1328313289
schema:
1328413290
$ref: '#/definitions/transaction'
1328513291
"429":
13286-
description: Too many open transactions
13287-
schema:
13288-
example:
13289-
code: 429
13290-
message: cannot start a new transaction, reached the maximum amount of 20 active transactions available
13291-
properties:
13292-
code:
13293-
type: integer
13294-
message:
13295-
type: string
13296-
type: object
13292+
$ref: '#/responses/TooManyRequests'
1329713293
default:
1329813294
$ref: '#/responses/DefaultError'
1329913295
summary: Start a new transaction
@@ -13429,17 +13425,7 @@ paths:
1342913425
schema:
1343013426
$ref: '#/definitions/spoe_transaction'
1343113427
"429":
13432-
description: Too many open transactions
13433-
schema:
13434-
example:
13435-
code: 429
13436-
message: cannot start a new transaction, reached the maximum amount of 20 active transactions available
13437-
properties:
13438-
code:
13439-
type: integer
13440-
message:
13441-
type: string
13442-
type: object
13428+
$ref: '#/responses/TooManyRequests'
1344313429
default:
1344413430
$ref: '#/responses/DefaultError'
1344513431
summary: Start a new transaction
@@ -14077,7 +14063,7 @@ paths:
1407714063
schema:
1407814064
$ref: '#/definitions/userlist'
1407914065
"404":
14080-
$ref: '#/responses/AlreadyExists'
14066+
$ref: '#/responses/NotFound'
1408114067
default:
1408214068
$ref: '#/responses/DefaultError'
1408314069
summary: Return one userlist
@@ -14202,7 +14188,7 @@ paths:
1420214188
schema:
1420314189
$ref: '#/definitions/user'
1420414190
"404":
14205-
$ref: '#/responses/AlreadyExists'
14191+
$ref: '#/responses/NotFound'
1420614192
default:
1420714193
$ref: '#/responses/DefaultError'
1420814194
summary: Return one userlist user
@@ -14370,7 +14356,7 @@ paths:
1437014356
schema:
1437114357
$ref: '#/definitions/group'
1437214358
"404":
14373-
$ref: '#/responses/AlreadyExists'
14359+
$ref: '#/responses/NotFound'
1437414360
default:
1437514361
$ref: '#/responses/DefaultError'
1437614362
summary: Return one userlist group
@@ -14703,7 +14689,7 @@ paths:
1470314689
schema:
1470414690
$ref: '#/definitions/mailer_entry'
1470514691
"404":
14706-
$ref: '#/responses/AlreadyExists'
14692+
$ref: '#/responses/NotFound'
1470714693
default:
1470814694
$ref: '#/responses/DefaultError'
1470914695
summary: Return one mailer_entry
@@ -14989,7 +14975,7 @@ paths:
1498914975
schema:
1499014976
$ref: '#/definitions/peer_entry'
1499114977
"404":
14992-
$ref: '#/responses/AlreadyExists'
14978+
$ref: '#/responses/NotFound'
1499314979
default:
1499414980
$ref: '#/responses/DefaultError'
1499514981
summary: Return one peer_entry
@@ -16321,7 +16307,7 @@ paths:
1632116307
schema:
1632216308
$ref: '#/definitions/bind'
1632316309
"404":
16324-
$ref: '#/responses/AlreadyExists'
16310+
$ref: '#/responses/NotFound'
1632516311
default:
1632616312
$ref: '#/responses/DefaultError'
1632716313
summary: Return one bind
@@ -16418,7 +16404,7 @@ paths:
1641816404
schema:
1641916405
$ref: '#/definitions/bind'
1642016406
"404":
16421-
$ref: '#/responses/AlreadyExists'
16407+
$ref: '#/responses/NotFound'
1642216408
default:
1642316409
$ref: '#/responses/DefaultError'
1642416410
summary: Return one bind
@@ -16515,7 +16501,7 @@ paths:
1651516501
schema:
1651616502
$ref: '#/definitions/bind'
1651716503
"404":
16518-
$ref: '#/responses/AlreadyExists'
16504+
$ref: '#/responses/NotFound'
1651916505
default:
1652016506
$ref: '#/responses/DefaultError'
1652116507
summary: Return one bind
@@ -16668,7 +16654,7 @@ paths:
1666816654
schema:
1666916655
$ref: '#/definitions/dgram_bind'
1667016656
"404":
16671-
$ref: '#/responses/AlreadyExists'
16657+
$ref: '#/responses/NotFound'
1667216658
default:
1667316659
$ref: '#/responses/DefaultError'
1667416660
summary: Return one dgram bind
@@ -20375,7 +20361,7 @@ paths:
2037520361
schema:
2037620362
$ref: '#/definitions/table'
2037720363
"404":
20378-
$ref: '#/responses/AlreadyExists'
20364+
$ref: '#/responses/NotFound'
2037920365
default:
2038020366
$ref: '#/responses/DefaultError'
2038120367
summary: Return one table
@@ -25319,13 +25305,7 @@ paths:
2531925305
schema:
2532025306
type: string
2532125307
default:
25322-
description: General Error
25323-
headers:
25324-
Configuration-Version:
25325-
description: Configuration file version
25326-
type: string
25327-
schema:
25328-
type: string
25308+
$ref: '#/responses/DefaultError'
2532925309
summary: Return HAProxy configuration
2533025310
tags:
2533125311
- Configuration
@@ -25394,21 +25374,9 @@ paths:
2539425374
schema:
2539525375
type: string
2539625376
"400":
25397-
description: Bad request
25398-
headers:
25399-
Configuration-Version:
25400-
description: Configuration file version
25401-
type: string
25402-
schema:
25403-
type: string
25377+
$ref: '#/responses/BadRequest'
2540425378
default:
25405-
description: General Error
25406-
headers:
25407-
Configuration-Version:
25408-
description: Configuration file version
25409-
type: string
25410-
schema:
25411-
type: string
25379+
$ref: '#/responses/DefaultError'
2541225380
summary: Push new haproxy configuration
2541325381
tags:
2541425382
- Configuration
@@ -27340,9 +27308,7 @@ paths:
2734027308
schema:
2734127309
type: string
2734227310
default:
27343-
description: General Error
27344-
schema:
27345-
type: string
27311+
$ref: '#/responses/DefaultError'
2734627312
summary: Dump per-task CPU profiling
2734727313
tags:
2734827314
- Profiling
@@ -27382,9 +27348,7 @@ paths:
2738227348
schema:
2738327349
type: string
2738427350
default:
27385-
description: General Error
27386-
schema:
27387-
type: string
27351+
$ref: '#/responses/DefaultError'
2738827352
summary: Dump memory usage profiling
2738927353
tags:
2739027354
- Profiling
@@ -28837,7 +28801,7 @@ paths:
2883728801
schema:
2883828802
$ref: '#/definitions/capture'
2883928803
"404":
28840-
$ref: '#/responses/AlreadyExists'
28804+
$ref: '#/responses/NotFound'
2884128805
default:
2884228806
$ref: '#/responses/DefaultError'
2884328807
summary: Return one declare capture
@@ -29030,7 +28994,7 @@ paths:
2903028994
schema:
2903128995
$ref: '#/definitions/ssl_front_use'
2903228996
"404":
29033-
$ref: '#/responses/AlreadyExists'
28997+
$ref: '#/responses/NotFound'
2903428998
default:
2903528999
$ref: '#/responses/DefaultError'
2903629000
summary: Return one SSLFrontUse
@@ -29183,7 +29147,7 @@ paths:
2918329147
schema:
2918429148
$ref: '#/definitions/force_be_switch'
2918529149
"404":
29186-
$ref: '#/responses/AlreadyExists'
29150+
$ref: '#/responses/NotFound'
2918729151
default:
2918829152
$ref: '#/responses/DefaultError'
2918929153
summary: Return one force-be-switch rule

‎specification/haproxy-spec.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,14 @@ responses:
803803
type: string
804804
schema:
805805
$ref: '#/definitions/error'
806+
TooManyRequests:
807+
description: Too many open transactions
808+
headers:
809+
Configuration-Version:
810+
description: Configuration file version
811+
type: string
812+
schema:
813+
$ref: '#/definitions/error'
806814
DefaultError:
807815
description: General Error
808816
headers:

‎specification/paths/configuration/bind.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ binds_one:
8080
schema:
8181
$ref: "#/definitions/bind"
8282
'404':
83-
$ref: '#/responses/AlreadyExists'
83+
$ref: '#/responses/NotFound'
8484
'default':
8585
$ref: '#/responses/DefaultError'
8686
put:

‎specification/paths/configuration/capture.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ captures_one:
7878
schema:
7979
$ref: "#/definitions/capture"
8080
'404':
81-
$ref: '#/responses/AlreadyExists'
81+
$ref: '#/responses/NotFound'
8282
'default':
8383
$ref: '#/responses/DefaultError'
8484
put:

‎specification/paths/configuration/dgram_bind.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ dgram_binds_one:
8080
schema:
8181
$ref: "#/definitions/dgram_bind"
8282
'404':
83-
$ref: '#/responses/AlreadyExists'
83+
$ref: '#/responses/NotFound'
8484
'default':
8585
$ref: '#/responses/DefaultError'
8686
put:

‎specification/paths/configuration/force_be_switch.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ force_be_switches_one:
8080
schema:
8181
$ref: "#/definitions/force_be_switch"
8282
'404':
83-
$ref: '#/responses/AlreadyExists'
83+
$ref: '#/responses/NotFound'
8484
'default':
8585
$ref: '#/responses/DefaultError'
8686
put:

‎specification/paths/configuration/mailers.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ mailer_entries_one:
253253
schema:
254254
$ref: "#/definitions/mailer_entry"
255255
'404':
256-
$ref: '#/responses/AlreadyExists'
256+
$ref: '#/responses/NotFound'
257257
'default':
258258
$ref: '#/responses/DefaultError'
259259
put:

‎specification/paths/configuration/peers.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ peer_entries_one:
204204
schema:
205205
$ref: "#/definitions/peer_entry"
206206
'404':
207-
$ref: '#/responses/AlreadyExists'
207+
$ref: '#/responses/NotFound'
208208
'default':
209209
$ref: '#/responses/DefaultError'
210210
put:

‎specification/paths/configuration/raw.yaml‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ configuration:
2424
schema:
2525
type: string
2626
'default':
27-
description: General Error
28-
headers:
29-
Configuration-Version:
30-
description: Configuration file version
31-
type: string
32-
schema:
33-
type: string
27+
$ref: '#/responses/DefaultError'
3428
post:
3529
summary: Push new haproxy configuration
3630
description: Push a new haproxy configuration file in plain text
@@ -99,18 +93,6 @@ configuration:
9993
schema:
10094
type: string
10195
'400':
102-
description: Bad request
103-
headers:
104-
Configuration-Version:
105-
description: Configuration file version
106-
type: string
107-
schema:
108-
type: string
96+
$ref: '#/responses/BadRequest'
10997
'default':
110-
description: General Error
111-
headers:
112-
Configuration-Version:
113-
description: Configuration file version
114-
type: string
115-
schema:
116-
type: string
98+
$ref: '#/responses/DefaultError'

‎specification/paths/configuration/ssl_front_use.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ssl_front_uses_one:
8080
schema:
8181
$ref: "#/definitions/ssl_front_use"
8282
'404':
83-
$ref: '#/responses/AlreadyExists'
83+
$ref: '#/responses/NotFound'
8484
'default':
8585
$ref: '#/responses/DefaultError'
8686
put:

0 commit comments

Comments
 (0)