tailscale/tailscale · error

QR code error: %w

Error message

QR code error: %w

What it means

Fired in Fprintln when qrcode.New fails to build a QR code from the input string (typically the string is too long for the QR capacity or contains unencodable data); the function returns without writing anything to the writer.

Source

Thrown at util/qrcodes/qrcodes.go:25

package qrcodes

import (
	"fmt"
	"io"
	"strings"

	qrcode "github.com/skip2/go-qrcode"
)

// Fprintln formats s according to [Format] and writes a QR code to w, along
// with a newline. It returns the number of bytes written and any write error
// encountered.
func Fprintln(w io.Writer, format Format, s string) (n int, err error) {
	const inverse = false // Modern scanners can read QR codes of any colour.

	q, err := qrcode.New(s, qrcode.Medium)
	if err != nil {
		return 0, fmt.Errorf("QR code error: %w", err)
	}

	if format == FormatAuto {
		format, err = detectFormat(w, inverse)
		if err != nil {
			return 0, fmt.Errorf("QR code error: %w", err)
		}
	}

	var out string
	switch format {
	case FormatASCII:
		out = q.ToString(inverse)
		out = strings.ReplaceAll(out, "█", "#")
	case FormatLarge:
		out = q.ToString(inverse)
	case FormatSmall:
		out = q.ToSmallString(inverse)

View on GitHub (pinned to 6e0912f979)

Solutions

  1. Shorten the string or use a URL instead of full text
  2. Ensure the payload is valid UTF-8 and within QR Medium capacity
  3. Surface the underlying qrcode error to the user
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at util/qrcodes/qrcodes.go:25 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tailscale/tailscale@6e0912f979 (2026-08-18). Data as JSON: /api/errors/4296ae8011096e03. Report an issue: GitHub.