[monorepo] remove PII and variables from error messages (#31508)

* [monorepo] remove PII and variables from error messages

Exclusions:
- scripts
- tests
- fuzzing
- SplitTestManager (messages are sent to admin frontend)
- Group setup (we may want an error per unique tuple)
- sharejs (unused types; text type errors are shadowed already)
- history-v1 error messages that are used by the ErrorRecorder
- errors that flag issues with configuration/call signatures

I've used these search terms for finding unwanted error messages:
- new Error(`
- new Error\(\n\s+` (regex search)
- new OError(`
- new OError\(\n\s+` (regex search)

* [web] throw NotFoundError from ProjectLocator

* [github-sync] fix OError.tag call in script

Co-authored-by: Jessica Lawshe <jessica.lawshe@overleaf.com>

* [templates] revert changes to test client

---------

Co-authored-by: Jessica Lawshe <jessica.lawshe@overleaf.com>
GitOrigin-RevId: 736857a4fc5d9bfb0f8cb03e0f004eda87e5a220
This commit is contained in:
Jakob Ackermann
2026-02-17 09:05:04 +00:00
committed by Copybot
co-authored by Jessica Lawshe
parent 1a1fa497fd
commit 7c70b749d4
32 changed files with 210 additions and 163 deletions
@@ -37,10 +37,12 @@ export function getDocument(projectId, docId, callback) {
)
return callback(null, body.lines.join('\n'), body.version)
} else {
error = new OError(
`doc updater returned a non-success status code: ${res.statusCode}`,
{ project_id: projectId, doc_id: docId, url }
)
error = new OError('doc updater returned a non-success status code', {
project_id: projectId,
doc_id: docId,
url,
statusCode: res.statusCode,
})
return callback(error)
}
})
@@ -69,10 +71,12 @@ export function setDocument(projectId, docId, content, userId, callback) {
if (res.statusCode >= 200 && res.statusCode < 300) {
return callback(null)
} else {
error = new OError(
`doc updater returned a non-success status code: ${res.statusCode}`,
{ project_id: projectId, doc_id: docId, url }
)
error = new OError('doc updater returned a non-success status code', {
project_id: projectId,
doc_id: docId,
url,
statusCode: res.statusCode,
})
return callback(error)
}
}
@@ -31,7 +31,9 @@ export function check(callback) {
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 200) {
return cb(new Error(`status code not 200, it's ${res.statusCode}`))
return cb(
new OError('status code not 200', { statusCode: res.statusCode })
)
} else {
return cb()
}
@@ -47,7 +49,9 @@ export function check(callback) {
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 204) {
return cb(new Error(`status code not 204, it's ${res.statusCode}`))
return cb(
new OError('status code not 204', { statusCode: res.statusCode })
)
} else {
return cb()
}
@@ -63,7 +67,9 @@ export function check(callback) {
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 200) {
return cb(new Error(`status code not 200, it's ${res.statusCode}`))
return cb(
new OError('status code not 200', { statusCode: res.statusCode })
)
} else {
return cb()
}
@@ -614,6 +614,7 @@ function _requestHistoryService(options, callback) {
} else {
const { method, url, qs } = requestOptions
error = new OError(
// Keep the status code in the message. It is used by the ErrorRecorder.
`history store a non-success status code: ${res.statusCode}`,
{ method, url, qs, statusCode: res.statusCode }
)