fix: a file the phone cannot read tells the customer to save it on the phone first, and Sentry learns its kind (DTF-WEB-2D)
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 8m14s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m22s

The same Android 10 phone failed three times on 2026-12-02 reading a file
seven seconds after picking it: not a permission lost over time, but a file
the phone does not have yet (Google Drive or WhatsApp). "Escolha o arquivo de
novo" sent the customer back to the same file. The message now says "Se ele
está no Google Drive ou no WhatsApp, salve no aparelho e escolha de novo".
The Sentry notice carries the browser's error name, the file's type,
extension and size in MB, never its name, so the next one says which case
it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 14:23:11 -03:00
parent 1633b995eb
commit fe5e9c4f4a
5 changed files with 20 additions and 5 deletions

View File

@@ -54,6 +54,13 @@ window.dtfObservability.uiError('Pastas automáticas: A última tentativa falhou
assert.ok(captured, 'uiError sends a caught error'); assert.ok(captured, 'uiError sends a caught error');
assert.equal(captured.message, 'Aviso kanban: Pastas automáticas: A última tentativa falhou: :arquivo bloqueado.'); assert.equal(captured.message, 'Aviso kanban: Pastas automáticas: A última tentativa falhou: :arquivo bloqueado.');
assert.deepEqual(captured.options.fingerprint, ['ui-error', 'kanban', 'Pastas automáticas: A última tentativa falhou: :arquivo bloqueado.']); assert.deepEqual(captured.options.fingerprint, ['ui-error', 'kanban', 'Pastas automáticas: A última tentativa falhou: :arquivo bloqueado.']);
// Extra detail (the kind of file a phone could not read, DTF-WEB-2D) rides along.
captured = null;
window.dtfObservability.uiError('Envio de arquivo falhou: não conseguimos ler este arquivo no aparelho.', 'site',
{erro: 'NotReadableError', extensao: 'png', mb: 12.5});
assert.equal(captured.options.extra.extensao, 'png');
assert.equal(captured.options.extra.mb, 12.5);
assert.ok(captured.options.extra.page);
apiError('/orders', 409, 'Falta a foto da revisão.'); apiError('/orders', 409, 'Falta a foto da revisão.');
captured = null; captured = null;
window.dtfObservability.uiError('Falta a foto da revisão.', 'kanban'); window.dtfObservability.uiError('Falta a foto da revisão.', 'kanban');

View File

@@ -188,7 +188,10 @@ const run = async (completeSteps, {abortAfter} = {}) => {
const {result, error, calls} = await run([{}]); const {result, error, calls} = await run([{}]);
assert.equal(result, undefined); assert.equal(result, undefined);
assert.equal(error?.unreadable, true); assert.equal(error?.unreadable, true);
assert.match(error.message, /Escolha o arquivo de novo/); assert.match(error.message, /salve no aparelho e escolha de novo/);
// Sentry learns the kind of file, never its name (DTF-WEB-2D).
assert.deepEqual(error.detalhe, {erro: 'NotReadableError', tipo: '', extensao: 'png', mb: 0});
assert.ok(!JSON.stringify(error.detalhe).includes('a.png'));
assert.equal(calls.length, 0, 'nothing reaches the server'); assert.equal(calls.length, 0, 'nothing reaches the server');
} finally { } finally {
globalThis.Blob = RealBlob; globalThis.Blob = RealBlob;

View File

@@ -284,7 +284,7 @@
if(window.dtfContaAberta&&typeof pintaPedido==='function')pintaPedido();}, if(window.dtfContaAberta&&typeof pintaPedido==='function')pintaPedido();},
error=>{envios.delete(k);if(error?.name!=='AbortError'){falhas.set(k,{file,error}); error=>{envios.delete(k);if(error?.name!=='AbortError'){falhas.set(k,{file,error});
// A refusal with a status already went to Sentry as an API error (DTF-WEB-15). // A refusal with a status already went to Sentry as an API error (DTF-WEB-15).
if(!error?.status)window.dtfObservability?.uiError?.('Envio de arquivo falhou: '+(error?.message||'erro no envio'),'site');}pintaEnvio();}); if(!error?.status)window.dtfObservability?.uiError?.('Envio de arquivo falhou: '+(error?.message||'erro no envio'),'site',error?.detalhe);}pintaEnvio();});
envios.set(k,e); envios.set(k,e);
} }
return e.promise; return e.promise;

View File

@@ -149,14 +149,14 @@
// Every error the page shows the user in red, also the ones it caught and // Every error the page shows the user in red, also the ones it caught and
// handled itself (a folder it could not write, an upload that failed): the // handled itself (a folder it could not write, an upload that failed): the
// team sees them in Sentry before anyone sends a screenshot. // team sees them in Sentry before anyone sends a screenshot.
function uiError(text, where) { function uiError(text, where, detail) {
if (!started || !text || typeof Sentry === 'undefined') return; if (!started || !text || typeof Sentry === 'undefined') return;
const said = recent.get(String(text)); const said = recent.get(String(text));
if (said && Date.now() - said < 15000) return; if (said && Date.now() - said < 15000) return;
try { try {
const kind = normalizedMessage(text); const kind = normalizedMessage(text);
Sentry.captureMessage('Aviso ' + (where || app) + ': ' + kind, Sentry.captureMessage('Aviso ' + (where || app) + ': ' + kind,
{level: 'error', tags: {app, aviso: where || app}, extra: {page: location.pathname}, {level: 'error', tags: {app, aviso: where || app}, extra: {page: location.pathname, ...(detail || {})},
fingerprint: ['ui-error', where || app, kind]}); fingerprint: ['ui-error', where || app, kind]});
} catch (error) { } catch (error) {
// Reporting an error must never break the page. // Reporting an error must never break the page.

View File

@@ -23,8 +23,13 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr
try{ sampled=await samples.arrayBuffer(); } try{ sampled=await samples.arrayBuffer(); }
catch(error){ catch(error){
if(error?.name!=='NotReadableError' && error?.name!=='NotFoundError') throw error; if(error?.name!=='NotReadableError' && error?.name!=='NotFoundError') throw error;
const unreadable=new Error('não conseguimos ler este arquivo no aparelho. Escolha o arquivo de novo'); // A file in Google Drive or WhatsApp that is not on the phone yet fails the
// same way, at once (DTF-WEB-2D): the message says how to get out of it.
const unreadable=new Error('não conseguimos ler este arquivo no aparelho. Se ele está no Google Drive ou no WhatsApp, salve no aparelho e escolha de novo');
unreadable.unreadable=true; unreadable.unreadable=true;
// For Sentry: what kind of file the phone refused, never its name.
const ext=/\.([a-z0-9]{1,5})$/i.exec(file.name||'')?.[1]?.toLowerCase()||'';
unreadable.detalhe={erro:error.name,tipo:file.type||'',extensao:ext,mb:Math.round((file.size||0)/1048576*10)/10};
throw unreadable; throw unreadable;
} }
const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',sampled)),b=>b.toString(16).padStart(2,'0')).join(''); const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',sampled)),b=>b.toString(16).padStart(2,'0')).join('');