Documentation
¶
Overview ¶
Package apierror renders errors with the response profile each client expects. Artifactory, Access, the OCI distribution API, Xray, npm and the Terraform registry all use different JSON shapes, and clients read them differently: jfrog-client-go prints the whole body after the status (only its release bundle import reads errors[0].message, and its Xray scan reads error), the Terraform providers join every errors[] entry, and Docker clients read errors[].code. One table here is the only place a shape is defined. See decision record 0002.
Index ¶
Constants ¶
const BasicChallenge = `Basic realm="Artifactory Realm"`
BasicChallenge is the WWW-Authenticate value of a 401: Artifactory's realm.
Variables ¶
var ErrNotImplemented = &Error{ Status: http.StatusNotImplemented, Code: "NOT_IMPLEMENTED", Message: "not implemented by artifactweave yet", }
ErrNotImplemented is returned by generated UnimplementedStrict stubs for operations the spec declares but no service implements yet. The strict response error handler renders it as 501 with the selected profile, so a scaffolded operation is visibly absent rather than a 500.
Functions ¶
Types ¶
type Error ¶
type Error struct {
Status int
Code string
Message string
Detail any
// NoChallenge distinguishes an upstream refusal from a request to authenticate
// against this server. Never turn upstream credentials into a local challenge.
NoChallenge bool
RetryAfterSeconds int
}
Error carries everything needed to render with any profile. Code is the OCI or Access symbolic code; Artifactory ignores it and uses Status.
func NotSupported ¶
NotSupported is the 501 answer for stubbed JFrog products. The message names artifactweave so operators reading a Terraform or jf error know the product is absent rather than broken.
type Profile ¶
type Profile int
Profile selects the error envelope, content type, and default authentication challenge. The zero value is ProfileArtifactory, the default under /artifactory.
const ( // ProfileArtifactory is {"errors":[{"status":404,"message":"..."}]}. ProfileArtifactory Profile = iota // ProfileAccess is {"errors":[{"code":"NOT_FOUND","message":"..."}]}, used by // /access and the Projects API. ProfileAccess // ProfileOCI is {"errors":[{"code":"BLOB_UNKNOWN","message":"...","detail":...}]}. ProfileOCI // ProfileXray is {"error":"..."}; served only by the 501 stubs. ProfileXray // ProfileNPM is {"error":"..."}; npm prints the field verbatim. ProfileNPM // ProfileTerraformRegistry is {"errors":["..."]}. ProfileTerraformRegistry // ProfileTerraformBackend is the JSON:API error document read by go-tfe. ProfileTerraformBackend // ProfileJFrogDistribution is {"status_code":404,"message":"...","errors":[{"status":404,"message":"..."}]}, // the shape JFrog Distribution documents; detail is added when set. ProfileJFrogDistribution // ProfileArtifactoryLegacy is the Artifactory envelope plus top-level error and // message, documented for cold storage retention: // {"errors":[{"status":400,"message":"..."}],"error":"Bad Request","message":"..."}. ProfileArtifactoryLegacy // ProfileImportExport is the Artifactory envelope plus a top-level error that // carries the message, documented for import and export: // {"errors":[{"status":400,"message":"..."}],"error":"..."}. ProfileImportExport // ProfilePlatformFederation is {"code":404,"message":"..."}, the HTTP status as // an integer code, used by the platform federation service (/pfed). ProfilePlatformFederation // ProfileGrid is {"code":"NOT_FOUND","message":"..."}, a symbolic code, with // details when set, used by the topology service (/grid). ProfileGrid // ProfileText is a plain-text body, used by the Go proxy: the go command shows // an error's body only when it is plain text (decision 0035). ProfileText // ProfileAPM is RFC 7807 problem JSON for the native Agent Package Manager. ProfileAPM // ProfileSwiftRegistry is RFC 7807 problem JSON for SwiftPM's registry API. ProfileSwiftRegistry // ProfilePub is the hosted Dart pub v2 error document. ProfilePub )