From 43b26c3f9a36874dca33cb01c2e318eb35dccbc3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 20:13:22 +0000 Subject: [PATCH] chore(deps): Bump github.com/go-openapi/errors from 0.22.4 to 0.22.7 Bumps [github.com/go-openapi/errors](https://github.com/go-openapi/errors) from 0.22.4 to 0.22.7. - [Release notes](https://github.com/go-openapi/errors/releases) - [Commits](https://github.com/go-openapi/errors/compare/v0.22.4...v0.22.7) --- updated-dependencies: - dependency-name: github.com/go-openapi/errors dependency-version: 0.22.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 8 +- .../go-openapi/errors/.editorconfig | 26 ++++ .../github.com/go-openapi/errors/.gitignore | 9 +- .../go-openapi/errors/.golangci.yml | 34 +++-- .../go-openapi/errors/CODE_OF_CONDUCT.md | 6 +- .../go-openapi/errors/CONTRIBUTORS.md | 25 ++++ vendor/github.com/go-openapi/errors/README.md | 116 +++++++++++++++++- .../github.com/go-openapi/errors/SECURITY.md | 37 ++++++ vendor/github.com/go-openapi/errors/api.go | 110 +++++++++++------ vendor/github.com/go-openapi/errors/auth.go | 2 +- vendor/github.com/go-openapi/errors/doc.go | 20 ++- .../github.com/go-openapi/errors/headers.go | 16 +-- .../go-openapi/errors/middleware.go | 3 +- .../github.com/go-openapi/errors/parsing.go | 9 +- vendor/github.com/go-openapi/errors/schema.go | 91 ++++++++------ vendor/modules.txt | 2 +- 17 files changed, 382 insertions(+), 134 deletions(-) create mode 100644 vendor/github.com/go-openapi/errors/.editorconfig create mode 100644 vendor/github.com/go-openapi/errors/CONTRIBUTORS.md create mode 100644 vendor/github.com/go-openapi/errors/SECURITY.md diff --git a/go.mod b/go.mod index 45d0f27..5f43096 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/obalunenko/strava-api go 1.25 require ( - github.com/go-openapi/errors v0.22.4 + github.com/go-openapi/errors v0.22.7 github.com/go-openapi/runtime v0.29.2 github.com/go-openapi/strfmt v0.25.0 github.com/go-openapi/swag v0.25.4 diff --git a/go.sum b/go.sum index fcead57..18834bb 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/analysis v0.24.1 h1:Xp+7Yn/KOnVWYG8d+hPksOYnCYImE3TieBa7rBOesYM= github.com/go-openapi/analysis v0.24.1/go.mod h1:dU+qxX7QGU1rl7IYhBC8bIfmWQdX4Buoea4TGtxXY84= -github.com/go-openapi/errors v0.22.4 h1:oi2K9mHTOb5DPW2Zjdzs/NIvwi2N3fARKaTJLdNabaM= -github.com/go-openapi/errors v0.22.4/go.mod h1:z9S8ASTUqx7+CP1Q8dD8ewGH/1JWFFLX/2PmAYNQLgk= +github.com/go-openapi/errors v0.22.7 h1:JLFBGC0Apwdzw3484MmBqspjPbwa2SHvpDm0u5aGhUA= +github.com/go-openapi/errors v0.22.7/go.mod h1://QW6SD9OsWtH6gHllUCddOXDL0tk0ZGNYHwsw4sW3w= github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= @@ -49,8 +49,8 @@ github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtP github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc= github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= -github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= -github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/go-openapi/testify/v2 v2.4.0 h1:8nsPrHVCWkQ4p8h1EsRVymA2XABB4OT40gcvAu+voFM= +github.com/go-openapi/testify/v2 v2.4.0/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= github.com/go-openapi/validate v0.25.1 h1:sSACUI6Jcnbo5IWqbYHgjibrhhmt3vR6lCzKZnmAgBw= github.com/go-openapi/validate v0.25.1/go.mod h1:RMVyVFYte0gbSTaZ0N4KmTn6u/kClvAFp+mAVfS/DQc= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= diff --git a/vendor/github.com/go-openapi/errors/.editorconfig b/vendor/github.com/go-openapi/errors/.editorconfig new file mode 100644 index 0000000..3152da6 --- /dev/null +++ b/vendor/github.com/go-openapi/errors/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/errors/.gitignore b/vendor/github.com/go-openapi/errors/.gitignore index dd91ed6..9364443 100644 --- a/vendor/github.com/go-openapi/errors/.gitignore +++ b/vendor/github.com/go-openapi/errors/.gitignore @@ -1,2 +1,7 @@ -secrets.yml -coverage.out +*.out +*.cov +.idea +.env +.mcp.json +.claude/ +settings.local.json diff --git a/vendor/github.com/go-openapi/errors/.golangci.yml b/vendor/github.com/go-openapi/errors/.golangci.yml index 5609b4f..e2c14be 100644 --- a/vendor/github.com/go-openapi/errors/.golangci.yml +++ b/vendor/github.com/go-openapi/errors/.golangci.yml @@ -2,34 +2,18 @@ version: "2" linters: default: all disable: - - cyclop - depguard - - errchkjson - - errorlint - - exhaustruct - - forcetypeassert - funlen - - gochecknoglobals - - gochecknoinits - - gocognit - - godot - godox - - gosmopolitan - - inamedparam - #- intrange # disabled while < go1.22 - - ireturn - - lll - - musttag - - nestif + - exhaustruct - nlreturn - - noinlineerr - nonamedreturns + - noinlineerr - paralleltest - recvcheck - testpackage - thelper - tparallel - - unparam - varnamelen - whitespace - wrapcheck @@ -41,8 +25,15 @@ linters: goconst: min-len: 2 min-occurrences: 3 + cyclop: + max-complexity: 20 gocyclo: - min-complexity: 45 + min-complexity: 20 + exhaustive: + default-signifies-exhaustive: true + default-case-required: true + lll: + line-length: 180 exclusions: generated: lax presets: @@ -50,6 +41,10 @@ linters: - common-false-positives - legacy - std-error-handling + rules: + - linters: + - revive + text: "avoid package names that conflict with Go standard library package names" paths: - third_party$ - builtin$ @@ -58,6 +53,7 @@ formatters: enable: - gofmt - goimports + - gofumpt exclusions: generated: lax paths: diff --git a/vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md index 9322b06..bac878f 100644 --- a/vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md +++ b/vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md @@ -23,7 +23,9 @@ include: Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or + advances + * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic @@ -55,7 +57,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at ivan+abuse@flanders.co.nz. All +reported by contacting the project team at . All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. @@ -68,7 +70,7 @@ members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +available at [][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/errors/CONTRIBUTORS.md b/vendor/github.com/go-openapi/errors/CONTRIBUTORS.md new file mode 100644 index 0000000..d49e377 --- /dev/null +++ b/vendor/github.com/go-openapi/errors/CONTRIBUTORS.md @@ -0,0 +1,25 @@ +# Contributors + +- Repository: ['go-openapi/errors'] + +| Total Contributors | Total Contributions | +| --- | --- | +| 13 | 110 | + +| Username | All Time Contribution Count | All Commits | +| --- | --- | --- | +| @casualjim | 58 | | +| @fredbi | 36 | | +| @youyuanwu | 5 | | +| @alexandear | 2 | | +| @fiorix | 1 | | +| @ligustah | 1 | | +| @artemseleznev | 1 | | +| @gautierdelorme | 1 | | +| @guillemj | 1 | | +| @maxatome | 1 | | +| @Simon-Li | 1 | | +| @aokumasan | 1 | | +| @ujjwalsh | 1 | | + + _this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_ diff --git a/vendor/github.com/go-openapi/errors/README.md b/vendor/github.com/go-openapi/errors/README.md index d7e3a18..d9f4a3f 100644 --- a/vendor/github.com/go-openapi/errors/README.md +++ b/vendor/github.com/go-openapi/errors/README.md @@ -1,12 +1,118 @@ -# OpenAPI errors [![Build Status](https://github.com/go-openapi/errors/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/errors/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/errors) +# errors -[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) -[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/errors/master/LICENSE) -[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/errors.svg)](https://pkg.go.dev/github.com/go-openapi/errors) -[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors) + +[![Tests][test-badge]][test-url] [![Coverage][cov-badge]][cov-url] [![CI vuln scan][vuln-scan-badge]][vuln-scan-url] [![CodeQL][codeql-badge]][codeql-url] + + + +[![Release][release-badge]][release-url] [![Go Report Card][gocard-badge]][gocard-url] [![CodeFactor Grade][codefactor-badge]][codefactor-url] [![License][license-badge]][license-url] + + +[![GoDoc][godoc-badge]][godoc-url] [![Discord Channel][discord-badge]][discord-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge] + +--- Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit. +## Announcements + +* **2025-12-19** : new community chat on discord + * a new discord community channel is available to be notified of changes and support users + * our venerable Slack channel remains open, and will be eventually discontinued on **2026-03-31** + +You may join the discord community by clicking the invite link on the discord badge (also above). [![Discord Channel][discord-badge]][discord-url] + +Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url] + +## Status + +API is stable. + +## Import this library in your project + +```cmd +go get github.com/go-openapi/errors +``` + +## Basic usage + +```go +const url = "https://www.example.com/#" + +errGeneric := New(401,"onvalid argument: %s", url) + +errNotFound := NotFound("resource not found: %s", url) + +errNotImplemented := NotImplemented("method: %s", url) +``` + +## Change log + +See + + + ## Licensing This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE). + + + +## Other documentation + +* [All-time contributors](./CONTRIBUTORS.md) +* [Contributing guidelines](.github/CONTRIBUTING.md) +* [Maintainers documentation](docs/MAINTAINERS.md) +* [Code style](docs/STYLE.md) + +## Cutting a new release + +Maintainers can cut a new release by either: + +* running [this workflow](https://github.com/go-openapi/errors/actions/workflows/bump-release.yml) +* or pushing a semver tag + * signed tags are preferred + * The tag message is prepended to release notes + + +[test-badge]: https://github.com/go-openapi/errors/actions/workflows/go-test.yml/badge.svg +[test-url]: https://github.com/go-openapi/errors/actions/workflows/go-test.yml +[cov-badge]: https://codecov.io/gh/go-openapi/errors/branch/master/graph/badge.svg +[cov-url]: https://codecov.io/gh/go-openapi/errors +[vuln-scan-badge]: https://github.com/go-openapi/errors/actions/workflows/scanner.yml/badge.svg +[vuln-scan-url]: https://github.com/go-openapi/errors/actions/workflows/scanner.yml +[codeql-badge]: https://github.com/go-openapi/errors/actions/workflows/codeql.yml/badge.svg +[codeql-url]: https://github.com/go-openapi/errors/actions/workflows/codeql.yml + +[release-badge]: https://badge.fury.io/gh/go-openapi%2Ferrors.svg +[release-url]: https://badge.fury.io/gh/go-openapi%2Ferrors + +[gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/errors +[gocard-url]: https://goreportcard.com/report/github.com/go-openapi/errors +[codefactor-badge]: https://img.shields.io/codefactor/grade/github/go-openapi/errors +[codefactor-url]: https://www.codefactor.io/repository/github/go-openapi/errors + +[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/errors +[godoc-url]: http://pkg.go.dev/github.com/go-openapi/errors +[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png +[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM +[slack-url]: https://goswagger.slack.com/archives/C04R30YMU +[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue +[discord-url]: https://discord.gg/twZ9BwT3 + + +[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg +[license-url]: https://github.com/go-openapi/errors/?tab=Apache-2.0-1-ov-file#readme + +[goversion-badge]: https://img.shields.io/github/go-mod/go-version/go-openapi/errors +[goversion-url]: https://github.com/go-openapi/errors/blob/master/go.mod +[top-badge]: https://img.shields.io/github/languages/top/go-openapi/errors +[commits-badge]: https://img.shields.io/github/commits-since/go-openapi/errors/latest diff --git a/vendor/github.com/go-openapi/errors/SECURITY.md b/vendor/github.com/go-openapi/errors/SECURITY.md new file mode 100644 index 0000000..6ceb159 --- /dev/null +++ b/vendor/github.com/go-openapi/errors/SECURITY.md @@ -0,0 +1,37 @@ +# Security Policy + +This policy outlines the commitment and practices of the go-openapi maintainers regarding security. + +## Supported Versions + +| Version | Supported | +| ------- | ------------------ | +| 0.x | :white_check_mark: | + +## Vulnerability checks in place + +This repository uses automated vulnerability scans, at every merged commit and at least once a week. + +We use: + +* [`GitHub CodeQL`][codeql-url] +* [`trivy`][trivy-url] +* [`govulncheck`][govulncheck-url] + +Reports are centralized in github security reports and visible only to the maintainers. + +## Reporting a vulnerability + +If you become aware of a security vulnerability that affects the current repository, +**please report it privately to the maintainers** +rather than opening a publicly visible GitHub issue. + +Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url]. + +> [!NOTE] +> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability". + +[codeql-url]: https://github.com/github/codeql +[trivy-url]: https://trivy.dev/docs/latest/getting-started +[govulncheck-url]: https://go.dev/blog/govulncheck +[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability diff --git a/vendor/github.com/go-openapi/errors/api.go b/vendor/github.com/go-openapi/errors/api.go index d39233b..d2b4427 100644 --- a/vendor/github.com/go-openapi/errors/api.go +++ b/vendor/github.com/go-openapi/errors/api.go @@ -5,6 +5,7 @@ package errors import ( "encoding/json" + "errors" "fmt" "net/http" "reflect" @@ -12,9 +13,11 @@ import ( ) // DefaultHTTPCode is used when the error Code cannot be used as an HTTP code. +// +//nolint:gochecknoglobals // it should have been a constant in the first place, but now it is mutable so we have to leave it here or introduce a breaking change. var DefaultHTTPCode = http.StatusUnprocessableEntity -// Error represents a error interface all swagger framework errors implement +// Error represents a error interface all swagger framework errors implement. type Error interface { error Code() int32 @@ -25,15 +28,17 @@ type apiError struct { message string } +// Error implements the standard error interface. func (a *apiError) Error() string { return a.message } +// Code returns the HTTP status code associated with this error. func (a *apiError) Code() int32 { return a.code } -// MarshalJSON implements the JSON encoding interface +// MarshalJSON implements the JSON encoding interface. func (a apiError) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]any{ "code": a.code, @@ -41,7 +46,7 @@ func (a apiError) MarshalJSON() ([]byte, error) { }) } -// New creates a new API error with a code and a message +// New creates a new API error with a code and a message. func New(code int32, message string, args ...any) Error { if len(args) > 0 { return &apiError{ @@ -55,7 +60,7 @@ func New(code int32, message string, args ...any) Error { } } -// NotFound creates a new not found error +// NotFound creates a new not found error. func NotFound(message string, args ...any) Error { if message == "" { message = "Not found" @@ -63,28 +68,29 @@ func NotFound(message string, args ...any) Error { return New(http.StatusNotFound, message, args...) } -// NotImplemented creates a new not implemented error +// NotImplemented creates a new not implemented error. func NotImplemented(message string) Error { return New(http.StatusNotImplemented, "%s", message) } -// MethodNotAllowedError represents an error for when the path matches but the method doesn't +// MethodNotAllowedError represents an error for when the path matches but the method doesn't. type MethodNotAllowedError struct { code int32 Allowed []string message string } +// Error implements the standard error interface. func (m *MethodNotAllowedError) Error() string { return m.message } -// Code the error code +// Code returns 405 (Method Not Allowed) as the HTTP status code. func (m *MethodNotAllowedError) Code() int32 { return m.code } -// MarshalJSON implements the JSON encoding interface +// MarshalJSON implements the JSON encoding interface. func (m MethodNotAllowedError) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]any{ "code": m.code, @@ -104,25 +110,33 @@ func errorAsJSON(err Error) []byte { func flattenComposite(errs *CompositeError) *CompositeError { var res []error - for _, er := range errs.Errors { - switch e := er.(type) { - case *CompositeError: - if e != nil && len(e.Errors) > 0 { - flat := flattenComposite(e) - if len(flat.Errors) > 0 { - res = append(res, flat.Errors...) - } - } - default: - if e != nil { - res = append(res, e) - } + + for _, err := range errs.Errors { + if err == nil { + continue + } + + e := &CompositeError{} + if !errors.As(err, &e) { + res = append(res, err) + + continue + } + + if len(e.Errors) == 0 { + res = append(res, e) + + continue } + + flat := flattenComposite(e) + res = append(res, flat.Errors...) } + return CompositeValidationError(res...) } -// MethodNotAllowed creates a new method not allowed error +// MethodNotAllowed creates a new method not allowed error. func MethodNotAllowed(requested string, allow []string) Error { msg := fmt.Sprintf("method %s is not allowed, but [%s] are", requested, strings.Join(allow, ",")) return &MethodNotAllowedError{ @@ -132,39 +146,55 @@ func MethodNotAllowed(requested string, allow []string) Error { } } -// ServeError implements the http error handler interface +// ServeError implements the [http] error handler interface. func ServeError(rw http.ResponseWriter, r *http.Request, err error) { rw.Header().Set("Content-Type", "application/json") - switch e := err.(type) { - case *CompositeError: - er := flattenComposite(e) + + if err == nil { + rw.WriteHeader(http.StatusInternalServerError) + _, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error"))) + + return + } + + errComposite := &CompositeError{} + errMethodNotAllowed := &MethodNotAllowedError{} + var errError Error + + switch { + case errors.As(err, &errComposite): + er := flattenComposite(errComposite) // strips composite errors to first element only if len(er.Errors) > 0 { ServeError(rw, r, er.Errors[0]) - } else { - // guard against empty CompositeError (invalid construct) - ServeError(rw, r, nil) + + return } - case *MethodNotAllowedError: - rw.Header().Add("Allow", strings.Join(e.Allowed, ",")) - rw.WriteHeader(asHTTPCode(int(e.Code()))) + + // guard against empty CompositeError (invalid construct) + ServeError(rw, r, nil) + + case errors.As(err, &errMethodNotAllowed): + rw.Header().Add("Allow", strings.Join(errMethodNotAllowed.Allowed, ",")) + rw.WriteHeader(asHTTPCode(int(errMethodNotAllowed.Code()))) if r == nil || r.Method != http.MethodHead { - _, _ = rw.Write(errorAsJSON(e)) + _, _ = rw.Write(errorAsJSON(errMethodNotAllowed)) } - case Error: - value := reflect.ValueOf(e) + + case errors.As(err, &errError): + value := reflect.ValueOf(errError) if value.Kind() == reflect.Ptr && value.IsNil() { rw.WriteHeader(http.StatusInternalServerError) _, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error"))) + return } - rw.WriteHeader(asHTTPCode(int(e.Code()))) + + rw.WriteHeader(asHTTPCode(int(errError.Code()))) if r == nil || r.Method != http.MethodHead { - _, _ = rw.Write(errorAsJSON(e)) + _, _ = rw.Write(errorAsJSON(errError)) } - case nil: - rw.WriteHeader(http.StatusInternalServerError) - _, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error"))) + default: rw.WriteHeader(http.StatusInternalServerError) if r == nil || r.Method != http.MethodHead { diff --git a/vendor/github.com/go-openapi/errors/auth.go b/vendor/github.com/go-openapi/errors/auth.go index 08de582..1173b56 100644 --- a/vendor/github.com/go-openapi/errors/auth.go +++ b/vendor/github.com/go-openapi/errors/auth.go @@ -5,7 +5,7 @@ package errors import "net/http" -// Unauthenticated returns an unauthenticated error +// Unauthenticated returns an unauthenticated error. func Unauthenticated(scheme string) Error { return New(http.StatusUnauthorized, "unauthenticated for %s", scheme) } diff --git a/vendor/github.com/go-openapi/errors/doc.go b/vendor/github.com/go-openapi/errors/doc.go index b4627f3..208c740 100644 --- a/vendor/github.com/go-openapi/errors/doc.go +++ b/vendor/github.com/go-openapi/errors/doc.go @@ -1,15 +1,13 @@ // SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers // SPDX-License-Identifier: Apache-2.0 -/* -Package errors provides an Error interface and several concrete types -implementing this interface to manage API errors and JSON-schema validation -errors. - -A middleware handler ServeError() is provided to serve the errors types -it defines. - -It is used throughout the various go-openapi toolkit libraries -(https://github.com/go-openapi). -*/ +// Package errors provides an Error interface and several concrete types +// implementing this interface to manage API errors and JSON-schema validation +// errors. +// +// A middleware handler [ServeError]() is provided to serve the errors types +// it defines. +// +// It is used throughout the various go-openapi toolkit libraries. +// (https://github.com/go-openapi). package errors diff --git a/vendor/github.com/go-openapi/errors/headers.go b/vendor/github.com/go-openapi/errors/headers.go index 2d837c3..717a51a 100644 --- a/vendor/github.com/go-openapi/errors/headers.go +++ b/vendor/github.com/go-openapi/errors/headers.go @@ -9,8 +9,8 @@ import ( "net/http" ) -// Validation represents a failure of a precondition -type Validation struct { //nolint: errname +// Validation represents a failure of a precondition. +type Validation struct { //nolint: errname // changing the name to abide by the naming rule would bring a breaking change. code int32 Name string In string @@ -19,16 +19,18 @@ type Validation struct { //nolint: errname Values []any } +// Error implements the standard error interface. func (e *Validation) Error() string { return e.message } -// Code the error code +// Code returns the HTTP status code for this validation error. +// Returns 422 (Unprocessable Entity) by default. func (e *Validation) Code() int32 { return e.code } -// MarshalJSON implements the JSON encoding interface +// MarshalJSON implements the JSON encoding interface. func (e Validation) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]any{ "code": e.code, @@ -40,7 +42,7 @@ func (e Validation) MarshalJSON() ([]byte, error) { }) } -// ValidateName sets the name for a validation or updates it for a nested property +// ValidateName sets the name for a validation or updates it for a nested property. func (e *Validation) ValidateName(name string) *Validation { if name != "" { if e.Name == "" { @@ -59,7 +61,7 @@ const ( responseFormatFail = `unsupported media type requested, only %v are available` ) -// InvalidContentType error for an invalid content type +// InvalidContentType error for an invalid content type. func InvalidContentType(value string, allowed []string) *Validation { values := make([]any, 0, len(allowed)) for _, v := range allowed { @@ -75,7 +77,7 @@ func InvalidContentType(value string, allowed []string) *Validation { } } -// InvalidResponseFormat error for an unacceptable response format request +// InvalidResponseFormat error for an unacceptable response format request. func InvalidResponseFormat(value string, allowed []string) *Validation { values := make([]any, 0, len(allowed)) for _, v := range allowed { diff --git a/vendor/github.com/go-openapi/errors/middleware.go b/vendor/github.com/go-openapi/errors/middleware.go index c434e59..f89275f 100644 --- a/vendor/github.com/go-openapi/errors/middleware.go +++ b/vendor/github.com/go-openapi/errors/middleware.go @@ -10,13 +10,14 @@ import ( ) // APIVerificationFailed is an error that contains all the missing info for a mismatched section -// between the api registrations and the api spec +// between the api registrations and the api spec. type APIVerificationFailed struct { //nolint: errname Section string `json:"section,omitempty"` MissingSpecification []string `json:"missingSpecification,omitempty"` MissingRegistration []string `json:"missingRegistration,omitempty"` } +// Error implements the standard error interface. func (v *APIVerificationFailed) Error() string { buf := bytes.NewBuffer(nil) diff --git a/vendor/github.com/go-openapi/errors/parsing.go b/vendor/github.com/go-openapi/errors/parsing.go index ea2a7c6..46e6612 100644 --- a/vendor/github.com/go-openapi/errors/parsing.go +++ b/vendor/github.com/go-openapi/errors/parsing.go @@ -9,7 +9,7 @@ import ( "net/http" ) -// ParseError represents a parsing error +// ParseError represents a parsing error. type ParseError struct { code int32 Name string @@ -19,7 +19,7 @@ type ParseError struct { message string } -// NewParseError creates a new parse error +// NewParseError creates a new parse error. func NewParseError(name, in, value string, reason error) *ParseError { var msg string if in == "" { @@ -37,16 +37,17 @@ func NewParseError(name, in, value string, reason error) *ParseError { } } +// Error implements the standard error interface. func (e *ParseError) Error() string { return e.message } -// Code returns the http status code for this error +// Code returns 400 (Bad Request) as the HTTP status code for parsing errors. func (e *ParseError) Code() int32 { return e.code } -// MarshalJSON implements the JSON encoding interface +// MarshalJSON implements the JSON encoding interface. func (e ParseError) MarshalJSON() ([]byte, error) { var reason string if e.Reason != nil { diff --git a/vendor/github.com/go-openapi/errors/schema.go b/vendor/github.com/go-openapi/errors/schema.go index e59ca4f..2378bae 100644 --- a/vendor/github.com/go-openapi/errors/schema.go +++ b/vendor/github.com/go-openapi/errors/schema.go @@ -5,6 +5,7 @@ package errors import ( "encoding/json" + "errors" "fmt" "net/http" "strings" @@ -62,14 +63,15 @@ const ( const maximumValidHTTPCode = 600 // All code responses can be used to differentiate errors for different handling -// by the consuming program +// by the consuming program. const ( // CompositeErrorCode remains 422 for backwards-compatibility - // and to separate it from validation errors with cause + // and to separate it from validation errors with cause. CompositeErrorCode = http.StatusUnprocessableEntity - // InvalidTypeCode is used for any subclass of invalid types + // InvalidTypeCode is used for any subclass of invalid types. InvalidTypeCode = maximumValidHTTPCode + iota + // RequiredFailCode indicates a required field is missing. RequiredFailCode TooLongFailCode TooShortFailCode @@ -90,22 +92,26 @@ const ( ReadOnlyFailCode ) -// CompositeError is an error that groups several errors together +// CompositeError is an error that groups several errors together. type CompositeError struct { Errors []error code int32 message string } -// Code for this error +// Code returns the HTTP status code for this composite error. func (c *CompositeError) Code() int32 { return c.code } +// Error implements the standard error interface. func (c *CompositeError) Error() string { if len(c.Errors) > 0 { msgs := []string{c.message + ":"} for _, e := range c.Errors { + if e == nil { + continue + } msgs = append(msgs, e.Error()) } return strings.Join(msgs, "\n") @@ -113,11 +119,12 @@ func (c *CompositeError) Error() string { return c.message } +// Unwrap implements the [errors.Unwrap] interface. func (c *CompositeError) Unwrap() []error { return c.Errors } -// MarshalJSON implements the JSON encoding interface +// MarshalJSON implements the JSON encoding interface. func (c CompositeError) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]any{ "code": c.code, @@ -126,7 +133,7 @@ func (c CompositeError) MarshalJSON() ([]byte, error) { }) } -// CompositeValidationError an error to wrap a bunch of other errors +// CompositeValidationError an error to wrap a bunch of other errors. func CompositeValidationError(errors ...error) *CompositeError { return &CompositeError{ code: CompositeErrorCode, @@ -135,20 +142,33 @@ func CompositeValidationError(errors ...error) *CompositeError { } } -// ValidateName recursively sets the name for all validations or updates them for nested properties +// ValidateName recursively sets the name for all validations or updates them for nested properties. func (c *CompositeError) ValidateName(name string) *CompositeError { for i, e := range c.Errors { - if ve, ok := e.(*Validation); ok { - c.Errors[i] = ve.ValidateName(name) - } else if ce, ok := e.(*CompositeError); ok { + if e == nil { + continue + } + + ce := &CompositeError{} + if errors.As(e, &ce) { c.Errors[i] = ce.ValidateName(name) + + continue + } + + ve := &Validation{} + if errors.As(e, &ve) { + c.Errors[i] = ve.ValidateName(name) + + continue } + } return c } -// FailedAllPatternProperties an error for when the property doesn't match a pattern +// FailedAllPatternProperties an error for when the property doesn't match a pattern. func FailedAllPatternProperties(name, in, key string) *Validation { msg := fmt.Sprintf(failedAllPatternProps, name, key, in) if in == "" { @@ -163,7 +183,7 @@ func FailedAllPatternProperties(name, in, key string) *Validation { } } -// PropertyNotAllowed an error for when the property doesn't match a pattern +// PropertyNotAllowed an error for when the property doesn't match a pattern. func PropertyNotAllowed(name, in, key string) *Validation { msg := fmt.Sprintf(unallowedProperty, name, key, in) if in == "" { @@ -178,7 +198,7 @@ func PropertyNotAllowed(name, in, key string) *Validation { } } -// TooFewProperties an error for an object with too few properties +// TooFewProperties an error for an object with too few properties. func TooFewProperties(name, in string, n int64) *Validation { msg := fmt.Sprintf(tooFewProperties, name, in, n) if in == "" { @@ -193,7 +213,7 @@ func TooFewProperties(name, in string, n int64) *Validation { } } -// TooManyProperties an error for an object with too many properties +// TooManyProperties an error for an object with too many properties. func TooManyProperties(name, in string, n int64) *Validation { msg := fmt.Sprintf(tooManyProperties, name, in, n) if in == "" { @@ -208,7 +228,7 @@ func TooManyProperties(name, in string, n int64) *Validation { } } -// AdditionalItemsNotAllowed an error for invalid additional items +// AdditionalItemsNotAllowed an error for invalid additional items. func AdditionalItemsNotAllowed(name, in string) *Validation { msg := fmt.Sprintf(noAdditionalItems, name, in) if in == "" { @@ -222,7 +242,7 @@ func AdditionalItemsNotAllowed(name, in string) *Validation { } } -// InvalidCollectionFormat another flavor of invalid type error +// InvalidCollectionFormat another flavor of invalid type error. func InvalidCollectionFormat(name, in, format string) *Validation { return &Validation{ code: InvalidTypeCode, @@ -233,7 +253,7 @@ func InvalidCollectionFormat(name, in, format string) *Validation { } } -// InvalidTypeName an error for when the type is invalid +// InvalidTypeName an error for when the type is invalid. func InvalidTypeName(typeName string) *Validation { return &Validation{ code: InvalidTypeCode, @@ -242,7 +262,7 @@ func InvalidTypeName(typeName string) *Validation { } } -// InvalidType creates an error for when the type is invalid +// InvalidType creates an error for when the type is invalid. func InvalidType(name, in, typeName string, value any) *Validation { var message string @@ -273,10 +293,9 @@ func InvalidType(name, in, typeName string, value any) *Validation { Value: value, message: message, } - } -// DuplicateItems error for when an array contains duplicates +// DuplicateItems error for when an array contains duplicates. func DuplicateItems(name, in string) *Validation { msg := fmt.Sprintf(uniqueFail, name, in) if in == "" { @@ -290,7 +309,7 @@ func DuplicateItems(name, in string) *Validation { } } -// TooManyItems error for when an array contains too many items +// TooManyItems error for when an array contains too many items. func TooManyItems(name, in string, maximum int64, value any) *Validation { msg := fmt.Sprintf(maximumItemsFail, name, in, maximum) if in == "" { @@ -306,7 +325,7 @@ func TooManyItems(name, in string, maximum int64, value any) *Validation { } } -// TooFewItems error for when an array contains too few items +// TooFewItems error for when an array contains too few items. func TooFewItems(name, in string, minimum int64, value any) *Validation { msg := fmt.Sprintf(minItemsFail, name, in, minimum) if in == "" { @@ -321,7 +340,7 @@ func TooFewItems(name, in string, minimum int64, value any) *Validation { } } -// ExceedsMaximumInt error for when maximumimum validation fails +// ExceedsMaximumInt error for when maximum validation fails. func ExceedsMaximumInt(name, in string, maximum int64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -346,7 +365,7 @@ func ExceedsMaximumInt(name, in string, maximum int64, exclusive bool, value any } } -// ExceedsMaximumUint error for when maximumimum validation fails +// ExceedsMaximumUint error for when maximum validation fails. func ExceedsMaximumUint(name, in string, maximum uint64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -371,7 +390,7 @@ func ExceedsMaximumUint(name, in string, maximum uint64, exclusive bool, value a } } -// ExceedsMaximum error for when maximumimum validation fails +// ExceedsMaximum error for when maximum validation fails. func ExceedsMaximum(name, in string, maximum float64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -396,7 +415,7 @@ func ExceedsMaximum(name, in string, maximum float64, exclusive bool, value any) } } -// ExceedsMinimumInt error for when minimum validation fails +// ExceedsMinimumInt error for when minimum validation fails. func ExceedsMinimumInt(name, in string, minimum int64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -421,7 +440,7 @@ func ExceedsMinimumInt(name, in string, minimum int64, exclusive bool, value any } } -// ExceedsMinimumUint error for when minimum validation fails +// ExceedsMinimumUint error for when minimum validation fails. func ExceedsMinimumUint(name, in string, minimum uint64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -446,7 +465,7 @@ func ExceedsMinimumUint(name, in string, minimum uint64, exclusive bool, value a } } -// ExceedsMinimum error for when minimum validation fails +// ExceedsMinimum error for when minimum validation fails. func ExceedsMinimum(name, in string, minimum float64, exclusive bool, value any) *Validation { var message string if in == "" { @@ -471,7 +490,7 @@ func ExceedsMinimum(name, in string, minimum float64, exclusive bool, value any) } } -// NotMultipleOf error for when multiple of validation fails +// NotMultipleOf error for when multiple of validation fails. func NotMultipleOf(name, in string, multiple, value any) *Validation { var msg string if in == "" { @@ -488,7 +507,7 @@ func NotMultipleOf(name, in string, multiple, value any) *Validation { } } -// EnumFail error for when an enum validation fails +// EnumFail error for when an enum validation fails. func EnumFail(name, in string, value any, values []any) *Validation { var msg string if in == "" { @@ -507,7 +526,7 @@ func EnumFail(name, in string, value any, values []any) *Validation { } } -// Required error for when a value is missing +// Required error for when a value is missing. func Required(name, in string, value any) *Validation { var msg string if in == "" { @@ -524,7 +543,7 @@ func Required(name, in string, value any) *Validation { } } -// ReadOnly error for when a value is present in request +// ReadOnly error for when a value is present in request. func ReadOnly(name, in string, value any) *Validation { var msg string if in == "" { @@ -541,7 +560,7 @@ func ReadOnly(name, in string, value any) *Validation { } } -// TooLong error for when a string is too long +// TooLong error for when a string is too long. func TooLong(name, in string, maximum int64, value any) *Validation { var msg string if in == "" { @@ -558,7 +577,7 @@ func TooLong(name, in string, maximum int64, value any) *Validation { } } -// TooShort error for when a string is too short +// TooShort error for when a string is too short. func TooShort(name, in string, minimum int64, value any) *Validation { var msg string if in == "" { @@ -596,7 +615,7 @@ func FailedPattern(name, in, pattern string, value any) *Validation { } // MultipleOfMustBePositive error for when a -// multipleOf factor is negative +// multipleOf factor is negative. func MultipleOfMustBePositive(name, in string, factor any) *Validation { return &Validation{ code: MultipleOfMustBePositiveCode, diff --git a/vendor/modules.txt b/vendor/modules.txt index b42df5f..ef6620b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -17,7 +17,7 @@ github.com/go-openapi/analysis/internal/flatten/operations github.com/go-openapi/analysis/internal/flatten/replace github.com/go-openapi/analysis/internal/flatten/schutils github.com/go-openapi/analysis/internal/flatten/sortref -# github.com/go-openapi/errors v0.22.4 +# github.com/go-openapi/errors v0.22.7 ## explicit; go 1.24.0 github.com/go-openapi/errors # github.com/go-openapi/jsonpointer v0.22.1