davila7/claude-code-templates · warning
⚠️ Could not generate QR code:
Error message
⚠️ Could not generate QR code:
What it means
generateQRCode builds a shareable session QR (rendering the session command to a data-URL image) and warns when QR generation fails, returning { dataUrl: null, command }. The command is still usable, so this degrades to a text-only sharing experience. Failure almost always comes from the underlying qrcode library (invalid input text, unsupported payload) or an encoding/render error.
Source
Thrown at cli-tool/src/session-sharing.js:435
try {
// Generate QR code as Data URL (for web display)
const qrDataUrl = await QRCode.toDataURL(command, {
errorCorrectionLevel: 'M',
type: 'image/png',
width: 300,
margin: 2,
color: {
dark: '#000000',
light: '#FFFFFF'
}
});
return {
dataUrl: qrDataUrl,
command: command
};
} catch (error) {
console.warn(chalk.yellow('⚠️ Could not generate QR code:'), error.message);
return {
dataUrl: null,
command: command
};
}
}
/**
* Sanitize project name for directory usage
* @param {string} projectName - Original project name
* @returns {string} Sanitized name
*/
sanitizeProjectName(projectName) {
// Replace spaces and special chars with hyphens
return projectName
.replace(/[^a-zA-Z0-9-_]/g, '-')
.replace(/-+/g, '-')
.toLowerCase();View on GitHub (pinned to a0851ed10c)
Solutions
- Verify the `qrcode` package is installed and importable (`node -e "require('qrcode')"`)
- Shorten the encoded payload (share a URL/short code instead of the full command) and re-run
- Pin or upgrade qrcode to a known-good version (`npm i qrcode@^1.5.x`)
- Fall back to the returned `command` string — copy/paste sharing still works without the QR
Example fix
// before
const qr = await generateQRCode(veryLongCommand);
// after
const qr = await generateQRCode(command);
if (!qr.dataUrl) {
console.log('Copy this command instead:', qr.command);
} Defensive patterns
Strategy: fallback
Validate before calling
if (typeof command !== 'string' || command.length === 0 || command.length > 2000) {
// skip QR, use text-only sharing
return { dataUrl: null, command };
} Try / catch
catch (error) {
return { dataUrl: null, command }; // always fall back to the plain command
} Prevention
- Keep the encoded payload short (short codes/URLs, not full tokens)
- Lock the qrcode dependency version in package.json
- Always render a copyable command alongside the QR so sharing works without it
When it happens
Trigger: Calling generateQRCode when the command string to encode is empty or too long for a QR code, when the qrcode dependency is missing or an incompatible version, or when toDataURL options are misconfigured (bad errorCorrectionLevel/format).
Common situations: Session token or command string grew beyond QR capacity (~2-3KB); qrcode package not installed after a partial npm install; running in an environment where the QR renderer's optional native deps are unavailable.
Related errors
- Invalid response from x0.at: ${uploadUrl || stderr}
- Download failed: ${stderr}
- Invalid session file - corrupted or not a Claude Code sessio
- Invalid session file - missing version
- Invalid session file - missing conversation data
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/7d3d89e837c2b381.
Report an issue: GitHub.