server: trace custom-page CSS rejections; fix scheduler lock-id comment
css_sanitizer emits warn! on unparseable CSS and complexity-limit rejection so abuse/regressions are visible. SCHEDULER_ADVISORY_LOCK_ID comment corrected: the literal encodes no ASCII mnemonic (the old "MNW_SCH" claim was wrong); left unchanged to avoid split lock IDs during a rolling deploy.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 files changed,
+12 insertions,
-1 deletion
| 86 |
86 |
|
let mut stylesheet = match StyleSheet::parse(input, parser_options()) {
|
| 87 |
87 |
|
Ok(s) => s,
|
| 88 |
88 |
|
Err(_) => {
|
|
89 |
+ |
tracing::warn!(input_len = input.len(), "custom-page CSS rejected: unparseable");
|
| 89 |
90 |
|
return (
|
| 90 |
91 |
|
String::new(),
|
| 91 |
92 |
|
vec![Rejection {
|
| 108 |
109 |
|
let _: Result<(), Infallible> = stylesheet.visit(&mut sanitizer);
|
| 109 |
110 |
|
|
| 110 |
111 |
|
if sanitizer.rule_count > MAX_RULES || sanitizer.selector_count > MAX_SELECTORS {
|
|
112 |
+ |
tracing::warn!(
|
|
113 |
+ |
rule_count = sanitizer.rule_count,
|
|
114 |
+ |
selector_count = sanitizer.selector_count,
|
|
115 |
+ |
"custom-page CSS rejected: exceeds complexity limits (MAX_RULES={MAX_RULES}, MAX_SELECTORS={MAX_SELECTORS})"
|
|
116 |
+ |
);
|
| 111 |
117 |
|
return (
|
| 112 |
118 |
|
String::new(),
|
| 113 |
119 |
|
vec![Rejection {
|
| 27 |
27 |
|
|
| 28 |
28 |
|
/// Advisory lock ID for single-instance scheduler coordination.
|
| 29 |
29 |
|
/// Prevents duplicate job execution during rolling deploys.
|
| 30 |
|
- |
const SCHEDULER_ADVISORY_LOCK_ID: i64 = 0x4D4E575F5343484; // "MNW_SCH" truncated
|
|
30 |
+ |
// Arbitrary fixed key — any stable, unique i64 works for pg_advisory_lock. (The
|
|
31 |
+ |
// value is not a real ASCII encoding of anything; an earlier comment claimed
|
|
32 |
+ |
// "MNW_SCH" but the literal has a stray nibble and decodes to no such string.
|
|
33 |
+ |
// Left as-is because changing it during a rolling deploy would briefly let old
|
|
34 |
+ |
// and new instances hold different keys and both run the scheduler.)
|
|
35 |
+ |
const SCHEDULER_ADVISORY_LOCK_ID: i64 = 0x4D4E575F5343484;
|
| 31 |
36 |
|
|
| 32 |
37 |
|
/// Weekly drift correction interval in scheduler ticks (10,080 = 7 days at 60s).
|
| 33 |
38 |
|
const DRIFT_CORRECTION_INTERVAL: u64 = 10_080;
|