You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(selfhost,observability): close three durable-wrong-state gaps, label the latency histogram, probe the browser, and add memory to host pressure (#9544, #9545) (#9547)
Copy file name to clipboardExpand all lines: src/selfhost/load-file-secrets.ts
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,9 @@ export function loadFileSecrets(
27
27
consttarget=key.slice(0,-"_FILE".length);
28
28
if(env[target])continue;// an explicit value wins
29
29
constpath=env[key]asstring;
30
+
letvalue: string;
30
31
try{
31
-
env[target]=readFile(path).trim();
32
+
value=readFile(path).trim();
32
33
}catch(error){
33
34
console.error(
34
35
JSON.stringify({
@@ -43,5 +44,26 @@ export function loadFileSecrets(
43
44
}`,
44
45
);
45
46
}
47
+
// #9487: an EMPTY (zero-byte or whitespace-only) secret file is as fatal as a missing one. Setting
48
+
// `env[target] = ""` looks like a successful load, but every downstream `nonBlank()` reads "" as
49
+
// UNCONFIGURED and preflight.ts deliberately skips absent values -- so a truncated
50
+
// GITHUB_WEBHOOK_SECRET file booted an instance that silently rejected every webhook. Directly adjacent
51
+
// to the known secret-rotation footgun on edge-nl-01, where a file is rewritten in place: the window in
52
+
// which it is momentarily empty is exactly when a container restart reads it.
53
+
//
54
+
// Checked OUTSIDE the try above on purpose: throwing inside it would be caught by that catch and
55
+
// re-reported as "unreadable", collapsing two genuinely different operator problems (a bad path/permission
56
+
// vs a truncated write) into one misleading message and the wrong log event.
57
+
if(value===""){
58
+
console.error(
59
+
JSON.stringify({
60
+
level: "error",
61
+
event: "selfhost_secret_file_empty",
62
+
var: key,
63
+
}),
64
+
);
65
+
thrownewError(`Secret file for ${key} (${path}) is empty; an empty secret silently reads as unconfigured downstream. Write the value, or unset ${key}.`);
0 commit comments