{"record":{"id":"f6e309e42d0ba2f9","repo":"kataras/iris","slug":"not-supported","errorCode":null,"errorMessage":"not supported","messagePattern":"not supported","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"context/context_user.go","lineNumber":16,"sourceCode":"package context\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"strings\"\n\t\"time\"\n\t\"unicode\"\n)\n\n// ErrNotSupported is fired when a specific method is not implemented\n// or not supported entirely.\n// Can be used by User implementations when\n// an authentication system does not implement a specific, but required,\n// method of the User interface.\nvar ErrNotSupported = errors.New(\"not supported\")\n\n// User is a generic view of an authorized client.\n// See `Context.User` and `SetUser` methods for more.\n//\n// The informational methods starts with a \"Get\" prefix\n// in order to allow the implementation to contain exported\n// fields such as `Username` so they can be JSON encoded when necessary.\n//\n// The caller is free to cast this with the implementation directly\n// when special features are offered by the authorization system.\n//\n// To make optional some of the fields you can just embed the User interface\n// and implement whatever methods you want to support.\n//\n// There are three builtin implementations of the User interface:\n// - SimpleUser\n// - UserMap (a wrapper by SetUser)\n// - UserPartial (a wrapper by SetUser)","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/context/context_user.go#L1-L34","documentation":"ErrNotSupported is a sentinel error meant to be returned by implementations of the framework's User interface (and compression helpers NewCompressWriter/NewCompressReader, GetEncoding, GetRoles, GetToken, GetField) when a specific required method is not implemented or not supported by the underlying authentication/compression system. The library defines it so implementations have a conventional, errors.Is-checkable way to signal missing capability.","triggerScenarios":"A custom authentication.User implementation stubbing GetRoles, GetToken, or GetField and returning this package's ErrNotSupported because the auth system (e.g. basic auth has no token/roles) cannot supply that data; middleware calling ctx.User().GetToken()/GetRoles()/GetField() against an implementation that doesn't support it; compression wrappers where the writer/reader type doesn't support the requested encoding.","commonSituations":"Basic-auth or third-party identity providers lacking roles/permissions while the app calls GetRoles; JWT flows calling GetField for claims that aren't present; switching auth providers and forgetting capability-dependent code paths; feature-detection code not using errors.Is(err, ErrNotSupported).","solutions":["Guard capability-dependent calls with errors.Is(err, context.ErrNotSupported) and degrade gracefully (skip roles/claims handling).","Choose an auth middleware/provider whose User implementation supports the methods you need (e.g. use a JWT-backed User for GetToken/GetField).","Implement the method in your custom User type instead of returning ErrNotSupported, or wrap another implementation that provides it.","For compression, verify the request's Accept-Encoding is registered/supported before relying on NewCompressWriter/Reader, or fall back to identity encoding."],"exampleFix":"// before\nroles, err := ctx.User().GetRoles()\nif err != nil {\n    return err // breaks with basic auth\n}\n\n// after\nroles, err := ctx.User().GetRoles()\nif errors.Is(err, context.ErrNotSupported) {\n    roles = nil // auth system has no roles; continue\n} else if err != nil {\n    return err\n}","handlingStrategy":"type-guard","validationCode":"// Feature-detect before relying on optional User capabilities:\nif _, err := ctx.User().GetToken(); errors.Is(err, context.ErrNotSupported) {\n    // token-based flows unavailable with this auth system\n}","typeGuard":"func supports(err error) bool { return !errors.Is(err, context.ErrNotSupported) }\n// usage: if supports(err) { ... } else { degrade }","tryCatchPattern":"v, err := ctx.User().GetField(\"org_id\")\nif errors.Is(err, context.ErrNotSupported) {\n    v = \"\" // unsupported by this auth provider\n} else if err != nil {\n    return err\n}","preventionTips":["Pick an auth provider whose User implementation supports every method your handlers call.","Wrap all optional capability calls (GetRoles, GetToken, GetField) in errors.Is(err, context.ErrNotSupported) checks.","When writing custom User implementations, prefer implementing the method over returning ErrNotSupported when feasible.","Verify compression/encoding support (Accept-Encoding) before using NewCompressWriter/Reader."],"tags":["authentication","user-interface","capability-detection","compression","iris"],"backgroundTag":"operation-not-supported","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}