-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathcodes.go
More file actions
205 lines (186 loc) · 8.97 KB
/
Copy pathcodes.go
File metadata and controls
205 lines (186 loc) · 8.97 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
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* 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 apperror
// Common, domain-agnostic catalog codes. These mirror the codes documented
// as shared response examples in resources/openapi.yaml, and are
// the fallback used by NewErrorResponse when a handler hasn't been
// migrated to a more specific domain code via NewErrorResponseWithCode.
const (
CodeCommonValidationFailed = "VALIDATION_FAILED"
CodeCommonUnauthorized = "UNAUTHORIZED"
CodeCommonForbidden = "FORBIDDEN"
CodeCommonNotFound = "NOT_FOUND"
CodeCommonConflict = "CONFLICT"
CodeCommonNotAcceptable = "NOT_ACCEPTABLE"
CodeCommonUnprocessableEntity = "UNPROCESSABLE_ENTITY"
CodeCommonInternalError = "INTERNAL_ERROR"
CodeCommonServiceUnavailable = "SERVICE_UNAVAILABLE"
CodeCommonTooManyRequests = "TOO_MANY_REQUESTS"
)
// LLM provider/proxy domain codes, matching the examples documented in
// resources/openapi.yaml for the corresponding operations.
const (
CodeLLMProviderNotFound = "LLM_PROVIDER_NOT_FOUND"
CodeLLMProviderExists = "LLM_PROVIDER_EXISTS"
CodeLLMProviderAPIKeyNotFound = "LLM_PROVIDER_API_KEY_NOT_FOUND"
CodeLLMProviderDeploymentValidationFailed = "LLM_PROVIDER_DEPLOYMENT_VALIDATION_FAILED"
CodeLLMProxyNotFound = "LLM_PROXY_NOT_FOUND"
CodeLLMProxyExists = "LLM_PROXY_EXISTS"
CodeLLMProxyAPIKeyNotFound = "LLM_PROXY_API_KEY_NOT_FOUND"
CodeLLMProviderRefNotFound = "LLM_PROVIDER_REF_NOT_FOUND"
CodeLLMProxyDeploymentValidationFailed = "LLM_PROXY_DEPLOYMENT_VALIDATION_FAILED"
CodeLLMProviderAPIKeyForbidden = "LLM_PROVIDER_API_KEY_FORBIDDEN"
CodeLLMProxyAPIKeyForbidden = "LLM_PROXY_API_KEY_FORBIDDEN"
CodeLLMProviderAPIKeyConflict = "LLM_PROVIDER_API_KEY_CONFLICT"
CodeLLMProxyAPIKeyConflict = "LLM_PROXY_API_KEY_CONFLICT"
)
// LLM provider template domain codes. The *_VERSION_* and *_REF_* codes keep
// one HTTP status per code in the apperror catalog: NOT_FOUND codes are 404s
// for the resource targeted by the URL, REF_NOT_FOUND codes are 400s for a
// resource referenced in the request body, and VERSION codes distinguish a
// missing/duplicate version from a missing/duplicate template.
const (
CodeLLMProviderTemplateNotFound = "LLM_PROVIDER_TEMPLATE_NOT_FOUND"
CodeLLMProviderTemplateVersionNotFound = "LLM_PROVIDER_TEMPLATE_VERSION_NOT_FOUND"
CodeLLMProviderTemplateRefNotFound = "LLM_PROVIDER_TEMPLATE_REF_NOT_FOUND"
CodeLLMProviderTemplateExists = "LLM_PROVIDER_TEMPLATE_EXISTS"
CodeLLMProviderTemplateVersionExists = "LLM_PROVIDER_TEMPLATE_VERSION_EXISTS"
CodeLLMProviderTemplateManagedByReserved = "LLM_PROVIDER_TEMPLATE_MANAGED_BY_RESERVED"
CodeLLMProviderTemplateInUse = "LLM_PROVIDER_TEMPLATE_IN_USE"
CodeLLMProviderTemplateDisabled = "LLM_PROVIDER_TEMPLATE_DISABLED"
CodeLLMProviderTemplateReadOnly = "LLM_PROVIDER_TEMPLATE_READ_ONLY"
CodeLLMProviderTemplateNotToggleable = "LLM_PROVIDER_TEMPLATE_NOT_TOGGLEABLE"
CodeLLMProviderTemplateBuiltInImmutable = "LLM_PROVIDER_TEMPLATE_BUILT_IN_IMMUTABLE"
)
// Gateway domain codes, matching the examples documented in resources/openapi.yaml.
const (
CodeGatewayNotFound = "GATEWAY_NOT_FOUND"
CodeGatewayTokenNotFound = "GATEWAY_TOKEN_NOT_FOUND"
CodeGatewayConnectionUnavailable = "GATEWAY_CONNECTION_UNAVAILABLE"
CodeGatewayHasActiveDeployments = "GATEWAY_HAS_ACTIVE_DEPLOYMENTS"
CodeGatewayNameConflict = "GATEWAY_NAME_CONFLICT"
CodeGatewayTokenLimitReached = "GATEWAY_TOKEN_LIMIT_REACHED"
)
// Deployment domain codes, shared across REST API / LLM provider / LLM proxy /
// MCP proxy deployment operations (identical conditions across all four).
const (
CodeBuildNotFound = "BUILD_NOT_FOUND"
CodeDeploymentBaseNotFound = "DEPLOYMENT_BASE_NOT_FOUND"
CodeDeploymentRestoreConflict = "DEPLOYMENT_RESTORE_CONFLICT"
CodeDeploymentNotFound = "DEPLOYMENT_NOT_FOUND"
CodeDeploymentNotActive = "DEPLOYMENT_NOT_ACTIVE"
CodeDeploymentGatewayMismatch = "DEPLOYMENT_GATEWAY_MISMATCH"
CodeDeploymentActive = "DEPLOYMENT_ACTIVE"
CodeDeploymentInvalidStatus = "DEPLOYMENT_INVALID_STATUS"
)
// REST API domain codes.
const (
CodeRESTAPINotFound = "REST_API_NOT_FOUND"
CodeRESTAPIExists = "REST_API_EXISTS"
CodeRESTAPIDeploymentValidationFailed = "REST_API_DEPLOYMENT_VALIDATION_FAILED"
CodeRESTAPIAPIKeyNotFound = "REST_API_API_KEY_NOT_FOUND"
CodeRESTAPIAPIKeyForbidden = "REST_API_API_KEY_FORBIDDEN"
)
// MCP proxy domain codes. MCP_PROXY_UPSTREAM_UNAUTHORIZED reports that the
// *remote* MCP server rejected our credentials — deliberately not a 401, so a
// client cannot confuse it with its own session expiring (see catalog.go).
const (
CodeMCPProxyNotFound = "MCP_PROXY_NOT_FOUND"
CodeMCPProxyExists = "MCP_PROXY_EXISTS"
CodeMCPProxyDeploymentValidationFailed = "MCP_PROXY_DEPLOYMENT_VALIDATION_FAILED"
CodeMCPProxyUpstreamUnauthorized = "MCP_PROXY_UPSTREAM_UNAUTHORIZED"
)
// Organization domain codes.
const (
CodeOrganizationNotFound = "ORGANIZATION_NOT_FOUND"
CodeOrganizationExists = "ORGANIZATION_EXISTS"
)
// Project domain codes. PROJECT_REF_NOT_FOUND is the 400 counterpart of
// PROJECT_NOT_FOUND for a project referenced in a request body (e.g. the
// projectId in a create request) rather than targeted by the URL.
const (
CodeProjectNotFound = "PROJECT_NOT_FOUND"
CodeProjectRefNotFound = "PROJECT_REF_NOT_FOUND"
CodeProjectExists = "PROJECT_EXISTS"
)
// Application domain codes.
const (
CodeApplicationNotFound = "APPLICATION_NOT_FOUND"
CodeApplicationExists = "APPLICATION_EXISTS"
)
// Subscription domain codes.
const (
CodeSubscriptionNotFound = "SUBSCRIPTION_NOT_FOUND"
CodeSubscriptionExists = "SUBSCRIPTION_EXISTS"
CodeSubscriptionForbidden = "SUBSCRIPTION_FORBIDDEN"
CodeSubscriptionPlanNotFound = "SUBSCRIPTION_PLAN_NOT_FOUND"
CodeSubscriptionPlanExists = "SUBSCRIPTION_PLAN_EXISTS"
)
// Custom policy domain codes.
const (
CodePolicyVersionConflict = "POLICY_VERSION_CONFLICT"
CodePolicyInvalidState = "POLICY_INVALID_STATE"
CodePolicyInUse = "POLICY_IN_USE"
)
// Secret domain codes.
const (
CodeSecretNotFound = "SECRET_NOT_FOUND"
CodeSecretExists = "SECRET_EXISTS"
CodeSecretInUse = "SECRET_IN_USE"
)
// Artifact domain codes. Used by flows that operate on a generic artifact
// reference (REST API / LLM provider / LLM proxy / MCP proxy) — API keys,
// subscriptions, and application associations — where the caller shouldn't
// need to know which concrete artifact kind was targeted, and by the
// data-plane-origin guard that protects DP-originated artifacts from
// control-plane mutation.
const (
CodeArtifactNotFound = "ARTIFACT_NOT_FOUND"
CodeArtifactExists = "ARTIFACT_EXISTS"
CodeArtifactReadOnly = "ARTIFACT_READ_ONLY"
CodeArtifactRuntimeImmutable = "ARTIFACT_RUNTIME_IMMUTABLE"
CodeArtifactDeployed = "ARTIFACT_DEPLOYED"
)
// Custom policy domain codes.
const (
CodeCustomPolicyNotFound = "CUSTOM_POLICY_NOT_FOUND"
CodeCustomPolicyVersionNotFound = "CUSTOM_POLICY_VERSION_NOT_FOUND"
)
// Application API key domain codes (application-scoped API key mappings,
// distinct from the LLM provider/proxy API key codes above).
const (
CodeApplicationAPIKeyNotFound = "APPLICATION_API_KEY_NOT_FOUND"
CodeApplicationAPIKeyForbidden = "APPLICATION_API_KEY_FORBIDDEN"
)
// WebSub and WebBroker API domain codes, raised by the event-gateway plugin
// and by the two gateway-internal artifact lookups.
const (
CodeWebSubAPINotFound = "WEBSUB_API_NOT_FOUND"
CodeWebSubAPIExists = "WEBSUB_API_EXISTS"
CodeWebBrokerAPINotFound = "WEBBROKER_API_NOT_FOUND"
CodeWebBrokerAPIExists = "WEBBROKER_API_EXISTS"
)
// HMAC secret domain codes (WebSub subscriber callback signing secrets).
// HMAC_SECRET_NOT_CONFIGURED is a 503 rather than a 500: the encryption key is
// a deployment-time setting, so the condition is transient from the client's
// point of view and resolvable without a code change.
const (
CodeHmacSecretNotFound = "HMAC_SECRET_NOT_FOUND"
CodeHmacSecretExists = "HMAC_SECRET_EXISTS"
CodeHmacSecretInvalidValue = "HMAC_SECRET_INVALID_VALUE"
CodeHmacSecretNotConfigured = "HMAC_SECRET_NOT_CONFIGURED"
)