{"record":{"id":"0a4af49f6798ce60","repo":"kataras/iris","slug":"version-w","errorCode":null,"errorMessage":"version %w","messagePattern":"version %w","errorType":"http","errorClass":"ErrNotFound","httpStatus":404,"severity":"error","filePath":"versioning/version.go","lineNumber":37,"sourceCode":"\tAcceptHeaderKey = \"Accept\"\n\t// AcceptHeaderVersionValue is the Accept's header value search term the requested version.\n\tAcceptHeaderVersionValue = \"version\"\n\t// NotFound is the key that can be used inside a `Map` or inside `ctx.SetVersion(versioning.NotFound)`\n\t// to tell that a version wasn't found, therefore the `NotFoundHandler` should handle the request instead.\n\tNotFound = \"iris.api.version.notfound\"\n\t// Empty is just an empty string. Can be used as a key for a version alias\n\t// when the requested version of a resource was not even specified by the client.\n\t// The difference between NotFound and Empty is important when version aliases are registered:\n\t// - A NotFound cannot be registered as version alias, it\n\t//   means that the client sent a version with its request\n\t//   but that version was not implemented by the server.\n\t// - An Empty indicates that the client didn't send any version at all.\n\tEmpty = \"\"\n)\n\n// ErrNotFound reports whether a requested version\n// does not match with any of the server's implemented ones.\nvar ErrNotFound = fmt.Errorf(\"version %w\", context.ErrNotFound)\n\n// NotFoundHandler is the default version not found handler that\n// is executed from `NewMatcher` when no version is registered as available to dispatch a resource.\nvar NotFoundHandler = func(ctx *context.Context) {\n\t// 303 is an option too,\n\t// end-dev has the chance to change that behavior by using the NotFound in the map:\n\t//\n\t// https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\n\t/*\n\t\t10.5.2 501 Not Implemented\n\n\t\tThe server does not support the functionality required to fulfill the request.\n\t\tThis is the appropriate response when the server does not\n\t\trecognize the request method and is not capable of supporting it for any resource.\n\t*/\n\n\tctx.StopWithPlainError(501, ErrNotFound)\n}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/versioning/version.go#L19-L55","documentation":"versioning.ErrNotFound wraps context.ErrNotFound and reports that a request's API version does not match any version the server has registered. It is a sentinel error used by the versioning matcher/handlers so callers can errors.Is-check it; the wrapped message surfaces as 'version not found'.","triggerScenarios":"A client sends a version header/param (e.g. 'X-API-Version: v9') that is not among the versions registered in versioning.NewGroup / NewMatcher; Get/GetByID/Update/Delete resource flows also return it when no version constraint matches.","commonSituations":"Client requesting a version the backend never registered (v9 when only v1–v3 exist), version string typos ('1.0' vs 'v1'), or after the server removed support for an old version.","solutions":["Register the requested version on the server via versioning.NewGroup(app, \"version\") for each supported version.","Fix the client to send a supported version string exactly as registered.","Configure a custom NotFound handler in the matcher map to negotiate/redirect to the closest supported version.","Remove client calls to deprecated versions and migrate to an active one."],"exampleFix":"// before (server only registers v2)\napi := versioning.NewGroup(app, \"/api\").Version(\"v2\")\n// after (client asks v1)\napi.Version(\"v1\")\napi.Version(\"v2\")","handlingStrategy":"try-catch","validationCode":"// client side: check the version is one the server advertises\nconst supported = [\"v1\", \"v2\"]\nif !slices.Contains(supported, requestedVersion) {\n    requestedVersion = \"v2\" // fallback\n}","typeGuard":null,"tryCatchPattern":"handler := versioning.NewMatcher(map[string]context.Handler{\n    \"v1\": h1, \"v2\": h2,\n})\n// in tests:\nif errors.Is(err, versioning.ErrNotFound) {\n    log.Println(\"client version unsupported; negotiate fallback\")\n}","preventionTips":["Publish the list of supported versions and validate client headers against it.","Register every supported version with versioning.NewGroup before serving.","Configure a custom NotFound handler that returns a machine-readable hint of available versions."],"tags":["versioning","routing","api-versioning"],"backgroundTag":"api-version-not-found","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}