-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy patherror.go
More file actions
322 lines (319 loc) · 13.8 KB
/
Copy patherror.go
File metadata and controls
322 lines (319 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
// Copyright 2026 The Bucketeer Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package api
import (
"github.com/bucketeer-io/bucketeer/v2/pkg/api/api"
pkgErr "github.com/bucketeer-io/bucketeer/v2/pkg/error"
)
var (
statusInternal = api.NewGRPCStatus(
pkgErr.NewErrorInternal(pkgErr.FeaturePackageName, "internal"))
statusMissingID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing id", "ID"))
statusMissingIDs = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing ids", "ID"))
statusInvalidID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(pkgErr.FeaturePackageName, "invalid id", "ID"))
statusMissingUser = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNil(pkgErr.FeaturePackageName, "missing user", "User"))
statusMissingUserID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing user id", "UserId"))
statusMissingFeatureIDs = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing feature ids", "FeatureFlagID"))
statusMissingDefaultOnVariation = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNil(pkgErr.FeaturePackageName, "missing default on variation", "DefaultOnVariation"))
statusMissingDefaultOffVariation = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNil(pkgErr.FeaturePackageName, "missing default off variation", "DefaultOffVariation"))
statusInvalidDefaultOnVariation = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"invalid default on variation",
"DefaultOnVariation",
))
statusInvalidDefaultOffVariation = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"invalid default off variation",
"DefaultOffVariation",
))
statusInvalidCursor = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(pkgErr.FeaturePackageName, "cursor is invalid", "Cursor"))
statusInvalidOrderBy = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(pkgErr.FeaturePackageName, "order_by is invalid", "OrderBy"))
statusMissingName = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing name", "Name"))
statusMissingFeatureVariations = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"feature must contain more than one variation",
"Variation",
))
statusMissingFeatureTags = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "feature must contain one or more tags", "Tag"))
statusCommentRequiredForUpdating = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "a comment is required for updating").
WithMessageKey("CommentRequiredForUpdating"))
statusMissingSegmentID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing segment id", "Segment"))
statusMissingSegmentUsersData = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing segment users data", "SegmentUser"))
statusExceededMaxSegmentUsersDataSize = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"max segment users data size exceeded",
"SegmentUserData",
maxSegmentUsersDataSize,
))
statusUnknownSegmentUserState = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgUnknown(
pkgErr.FeaturePackageName,
"unknown segment user state",
"SegmentUserState",
))
statusIncorrectDestinationEnvironment = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"destination environment is the same as origin one",
"DestinationEnvironment",
))
statusMissingEnvironmentID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"environment_id is required",
"EnvironmentId",
))
statusMissingTargetEnvironments = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"target_environment_ids must not be empty",
"TargetEnvironmentIds",
))
statusDuplicateTargetEnvironments = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgDuplicated(
pkgErr.FeaturePackageName,
"target_environment_ids must not contain duplicates",
"TargetEnvironmentIds",
))
statusExceededMaxPageSizePerRequest = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"max page size allowed is exceeded",
"PageSize",
maxPageSizePerRequest,
))
statusFeatureNotFound = api.NewGRPCStatus(
pkgErr.NewErrorNotFound(pkgErr.FeaturePackageName, "not found", "FeatureFlag"))
statusSegmentNotFound = api.NewGRPCStatus(
pkgErr.NewErrorNotFound(pkgErr.FeaturePackageName, "segment not found", "Segment"))
statusAlreadyExists = api.NewGRPCStatus(
pkgErr.NewErrorAlreadyExists(pkgErr.FeaturePackageName, "already exists"))
statusSegmentUsersAlreadyUploading = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "segment users already uploading").
WithMessageKey("SegmentUsersAlreadyUploading"))
statusSegmentStatusNotSucceeded = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "segment status is not succeeded").
WithMessageKey("SegmentStatusNotSucceeded"))
statusSegmentInUse = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "segment is in use").
WithMessageKey("SegmentInUse"))
// segment rules
statusExceededMaxSegmentRules = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"max number of segment rules exceeded",
"SegmentRules",
maxSegmentRules,
))
statusExceededMaxSegmentRuleClauses = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"max number of clauses per segment rule exceeded",
"SegmentRuleClauses",
maxSegmentRuleClauses,
))
statusSegmentRuleRequired = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNil(pkgErr.FeaturePackageName, "segment rule must not be nil", "SegmentRule"))
statusInvalidSegmentRuleID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"segment rule id must be a valid uuid",
"SegmentRuleId",
))
statusDuplicateSegmentRuleID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgDuplicated(
pkgErr.FeaturePackageName,
"segment rule ids must not contain duplicates",
"SegmentRuleId",
))
statusSegmentRuleStrategyNotAllowed = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"strategy must not be set on segment rules",
"SegmentRuleStrategy",
))
statusSegmentRuleClauseRequired = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"segment rule must have at least one clause",
"SegmentRuleClause",
))
statusInvalidSegmentRuleClauseID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"segment rule clause id must be a valid uuid",
"SegmentRuleClauseId",
))
statusDuplicateSegmentRuleClauseID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgDuplicated(
pkgErr.FeaturePackageName,
"segment rule clause ids must not contain duplicates",
"SegmentRuleClauseId",
))
statusSegmentRuleOperatorNotAllowed = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgUnknown(
pkgErr.FeaturePackageName,
"segment and feature flag operators are not allowed in segment rules",
"SegmentRuleClauseOperator",
))
statusSegmentRuleClauseAttributeRequired = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"segment rule clause attribute must not be empty",
"SegmentRuleClauseAttribute",
))
statusSegmentRuleClauseValuesRequired = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"segment rule clause values must not be empty",
"SegmentRuleClauseValues",
))
statusUnauthenticated = api.NewGRPCStatus(
pkgErr.NewErrorUnauthenticated(pkgErr.FeaturePackageName, "unauthenticated"))
statusPermissionDenied = api.NewGRPCStatus(
pkgErr.NewErrorPermissionDenied(pkgErr.FeaturePackageName, "permission denied"))
statusWaitingOrRunningExperimentExists = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "experiment in waiting or running status exists").
WithMessageKey("HasWaitingOrRunningExperiment"))
statusInvalidArchive = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(
pkgErr.FeaturePackageName,
"can't archive because this feature is used as a prerequisite").
WithMessageKey("InvalidArchive"))
// flag trigger
statusMissingTriggerFeatureID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing trigger feature id", "FeatureFlagID"))
statusMissingTriggerType = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing trigger type", "TriggerType"))
statusMissingTriggerAction = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing trigger action", "TriggerAction"))
statusMissingTriggerID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing trigger id", "TriggerId"))
statusSecretRequired = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "trigger secret is required", "TriggerSecret"))
statusTriggerAlreadyDisabled = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "trigger already disabled").
WithMessageKey("TriggerAlreadyDisabled"))
statusTriggerNotFound = api.NewGRPCStatus(
pkgErr.NewErrorNotFound(pkgErr.FeaturePackageName, "trigger not found", "FlagTrigger"))
statusTriggerDisableFailed = api.NewGRPCStatus(
pkgErr.NewErrorInternal(pkgErr.FeaturePackageName, "trigger disable failed"))
statusTriggerEnableFailed = api.NewGRPCStatus(
pkgErr.NewErrorInternal(pkgErr.FeaturePackageName, "trigger enable failed"))
statusTriggerActionInvalid = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgUnknown(pkgErr.FeaturePackageName, "trigger action is invalid", "TriggerAction"))
statusTriggerUsageUpdateFailed = api.NewGRPCStatus(
pkgErr.NewErrorInternal(pkgErr.FeaturePackageName, "trigger usage update failed"))
// scheduled flag change
statusMissingScheduledFlagChangeID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(
pkgErr.FeaturePackageName,
"missing scheduled flag change id",
"ScheduledFlagChangeId",
))
statusMissingFeatureID = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing feature id", "FeatureFlagID"))
statusMissingScheduledAt = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "missing scheduled at", "ScheduledAt"))
statusMissingPayload = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNil(pkgErr.FeaturePackageName, "missing payload", "Payload"))
statusScheduledTimeTooSoon = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"scheduled time must be at least 1 minute in the future",
"ScheduledAt",
))
statusScheduledTimeTooClose = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"scheduled time must be at least 5 minutes apart from other schedules for this flag",
"ScheduledAt",
))
statusScheduledTimeTooFar = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"scheduled time must be at most 1 year in the future",
"ScheduledAt",
))
statusExceededMaxSchedulesPerFlag = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"exceeded maximum number of schedules per flag",
"SchedulesPerFlag",
maxSchedulesPerFlag,
))
statusExceededMaxChangesPerSchedule = api.NewGRPCStatus(
pkgErr.NewErrorExceededMax(
pkgErr.FeaturePackageName,
"exceeded maximum number of changes per schedule",
"ChangesPerSchedule",
maxChangesPerSchedule,
))
statusScheduledFlagChangeNotFound = api.NewGRPCStatus(
pkgErr.NewErrorNotFound(pkgErr.FeaturePackageName, "scheduled flag change not found", "ScheduledFlagChange"))
statusScheduledFlagChangeNotPending = api.NewGRPCStatus(
pkgErr.NewErrorFailedPrecondition(pkgErr.FeaturePackageName, "scheduled flag change is not pending").
WithMessageKey("ScheduledFlagChangeNotPending"))
statusEmptyPayload = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgEmpty(pkgErr.FeaturePackageName, "payload must contain at least one change", "Payload"))
statusInvalidVariationReference = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"invalid variation reference in payload",
"VariationId",
))
statusInvalidRuleReference = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"invalid rule reference in payload",
"RuleId",
))
statusInvalidPrerequisiteReference = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"invalid prerequisite reference in payload: referenced feature or variation does not exist",
"PrerequisiteId",
))
statusCircularPrerequisiteDetected = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"scheduling this prerequisite change would create a circular dependency",
"PrerequisiteId",
))
statusInvalidRuleOrder = api.NewGRPCStatus(
pkgErr.NewErrorInvalidArgNotMatchFormat(
pkgErr.FeaturePackageName,
"ordered_rule_ids must contain exactly one entry per rule with no duplicates",
"OrderedRuleIds",
))
)