kataras/iris · warning

not supported

Error message

not supported

What it means

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.

Source

Thrown at context/context_user.go:16

package context

import (
	"encoding/json"
	"errors"
	"strings"
	"time"
	"unicode"
)

// ErrNotSupported is fired when a specific method is not implemented
// or not supported entirely.
// Can be used by User implementations when
// an authentication system does not implement a specific, but required,
// method of the User interface.
var ErrNotSupported = errors.New("not supported")

// User is a generic view of an authorized client.
// See `Context.User` and `SetUser` methods for more.
//
// The informational methods starts with a "Get" prefix
// in order to allow the implementation to contain exported
// fields such as `Username` so they can be JSON encoded when necessary.
//
// The caller is free to cast this with the implementation directly
// when special features are offered by the authorization system.
//
// To make optional some of the fields you can just embed the User interface
// and implement whatever methods you want to support.
//
// There are three builtin implementations of the User interface:
// - SimpleUser
// - UserMap (a wrapper by SetUser)
// - UserPartial (a wrapper by SetUser)

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Guard capability-dependent calls with errors.Is(err, context.ErrNotSupported) and degrade gracefully (skip roles/claims handling).
  2. Choose an auth middleware/provider whose User implementation supports the methods you need (e.g. use a JWT-backed User for GetToken/GetField).
  3. Implement the method in your custom User type instead of returning ErrNotSupported, or wrap another implementation that provides it.
  4. For compression, verify the request's Accept-Encoding is registered/supported before relying on NewCompressWriter/Reader, or fall back to identity encoding.

Example fix

// before
roles, err := ctx.User().GetRoles()
if err != nil {
    return err // breaks with basic auth
}

// after
roles, err := ctx.User().GetRoles()
if errors.Is(err, context.ErrNotSupported) {
    roles = nil // auth system has no roles; continue
} else if err != nil {
    return err
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Feature-detect before relying on optional User capabilities:
if _, err := ctx.User().GetToken(); errors.Is(err, context.ErrNotSupported) {
    // token-based flows unavailable with this auth system
}

Type guard

func supports(err error) bool { return !errors.Is(err, context.ErrNotSupported) }
// usage: if supports(err) { ... } else { degrade }

Try / catch

v, err := ctx.User().GetField("org_id")
if errors.Is(err, context.ErrNotSupported) {
    v = "" // unsupported by this auth provider
} else if err != nil {
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/f6e309e42d0ba2f9. Report an issue: GitHub.