{"record":{"id":"4296ae8011096e03","repo":"tailscale/tailscale","slug":"qr-code-error-w","errorCode":null,"errorMessage":"QR code error: %w","messagePattern":"QR code error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/qrcodes/qrcodes.go","lineNumber":25,"sourceCode":"package qrcodes\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n\n\tqrcode \"github.com/skip2/go-qrcode\"\n)\n\n// Fprintln formats s according to [Format] and writes a QR code to w, along\n// with a newline. It returns the number of bytes written and any write error\n// encountered.\nfunc Fprintln(w io.Writer, format Format, s string) (n int, err error) {\n\tconst inverse = false // Modern scanners can read QR codes of any colour.\n\n\tq, err := qrcode.New(s, qrcode.Medium)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"QR code error: %w\", err)\n\t}\n\n\tif format == FormatAuto {\n\t\tformat, err = detectFormat(w, inverse)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"QR code error: %w\", err)\n\t\t}\n\t}\n\n\tvar out string\n\tswitch format {\n\tcase FormatASCII:\n\t\tout = q.ToString(inverse)\n\t\tout = strings.ReplaceAll(out, \"█\", \"#\")\n\tcase FormatLarge:\n\t\tout = q.ToString(inverse)\n\tcase FormatSmall:\n\t\tout = q.ToSmallString(inverse)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/util/qrcodes/qrcodes.go#L7-L43","documentation":"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.","triggerScenarios":"Thrown at util/qrcodes/qrcodes.go:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Shorten the string or use a URL instead of full text","Ensure the payload is valid UTF-8 and within QR Medium capacity","Surface the underlying qrcode error to the user"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}