How to Lock monday.com Columns After Approval Without Triggering Infinite Webhook Revert Loops
If you have ever built an approval workflow on monday.com, you hit the same wall in week one. Stakeholders want a simple rule: once Finance or Legal signs off on an item, nobody should be able to quietly bump the budget from $12,000 to $18,000 or swap the attached contract PDF.
Native column permissions are static. You cannot say "allow edits while Pending, lock these four columns once Approved" without enforcing the lock in your backend via webhooks.
So you subscribe to change_column_value, detect an unauthorized edit on a locked item, and call change_column_value via GraphQL to revert it. Ten minutes into staging, your server loops itself into a rate-limit ban.
Your revert mutation fires another change_column_value webhook right back at you. Comparing raw JSON strings will not stop it: monday.com injects volatile keys (changed_at, updated_at, post_id), serializes numbers as "100" in one path and 100 in another, and shifts status cells between { index: 1 } and { label: "Approved" }.
Here is the three-layer defense we shipped in TypeScript, plus the optimistic concurrency control and signed audit receipts behind it.
Layer 1: Deterministic 1-Hop Echo Termination
Before touching GraphQL, handleTamperWebhook runs a sub-5ms fast path: load the approval doc from MongoDB and bail if !approval || !approval.isLocked, or if the column is outside protectedColumnIds, statusColumnId, and NON_REVERTIBLE_TYPES. Normal board edits cost zero GraphQL calls.
For locked columns, we stop the revert echo in a single hop by running both the stored approval snapshot and incoming webhook payloads through canonicalizeColumnValue (tamperGuard.ts):
const VOLATILE_KEYS = new Set(["changed_at", "updated_at", "post_id"]);
const NON_REVERTIBLE_TYPES = new Set(["file", "files", "formula", "mirror"]);
function stripVolatileAndSort(input: unknown): unknown {
if (input === null || input === undefined) return null;
if (Array.isArray(input)) return input.map((v) => stripVolatileAndSort(v));
if (typeof input === "object") {
const out: Record<string, unknown> = {};
for (const [k, v] of Object.entries(input as Record<string, unknown>)
.filter(([k]) => !VOLATILE_KEYS.has(k))
.sort(([a], [b]) => a.localeCompare(b))) {
out[k] = stripVolatileAndSort(v);
}
return out;
}
return input;
}
export function canonicalizeColumnValue(columnType: string, rawValue: unknown): string {
const parsed = parseJsonIfString(rawValue);
if (parsed === null || parsed === undefined || parsed === "") return JSON.stringify(null);
const t = columnType.toLowerCase();
if (t === "numbers" || t === "numeric") {
if (typeof parsed === "number") return JSON.stringify(String(parsed));
if (typeof parsed === "string") {
const n = Number(parsed);
return JSON.stringify(Number.isFinite(n) ? String(n) : parsed.trim());
}
}
if (t === "status" || t === "color") {
if (typeof parsed === "object" && parsed !== null) {
const obj = parsed as Record<string, unknown>;
if (obj.index !== undefined) return JSON.stringify({ index: Number(obj.index) });
if (obj.label !== undefined) return JSON.stringify({ label: String(obj.label) });
}
}
return JSON.stringify(stripVolatileAndSort(parsed));
}
When a user edits a locked cell, incomingNorm !== expectedNorm, so we write expectedNorm back. When monday.com echoes our revert, canonicalizeColumnValue strips the fresh changed_at, sorts keys, matches expectedNorm identically, and exits with { action: "ignore_echo" }.
One real quirk in buildLockedColumnSnapshot: GraphQL reads on status columns sometimes omit label in raw value JSON while populating text. We prefer col.text when snapshotting and pin statusColumnId to JSON.stringify({ label: "Approved" }) so our own post-approval status sync never false-positives.
Layer 2: Atomic 15-Second Revert Leases
Echo canonicalization stops clean ping-pong loops, not a user editing a locked cell four times in two seconds or duplicate webhooks arriving while the first GraphQL revert is still in flight. Without a lock, concurrent handlers both miss the echo check, fire duplicate reverts, and spam the Updates feed.
We gate every revert behind a 15-second atomic lease keyed by rev:${accountId}:${event.itemId}:${event.columnId} with a SHA-256 targetHash. In MongoDB, acquireRevertLease runs a single findOneAndUpdate upsert backed by a TTL index on lockedUntil (expireAfterSeconds: 0):
const doc = await this.revertLeases.findOneAndUpdate(
{
_id: params.key,
$or: [{ lockedUntil: { $lte: now } }, { lockedUntil: { $exists: false } }],
},
{ $set: { targetHash: params.targetHash, lockedUntil: nextExpiry } },
{ upsert: true, returnDocument: "after" }
);
return doc?.lockedUntil.getTime() === nextExpiry.getTime();
If an active lease exists, the filter misses and MongoDB throws a duplicate-key error on upsert. We catch it, return false, and exit with { action: "suppressed_by_lease" }.
Layer 3: Forensic Diffing for Non-Revertible File Columns
You cannot revert a FileValue column through change_column_value, and monday.com's public_url links expire after an hour, so persisting them is both broken and unsafe (we guard against it with assertNoTransientPublicUrl).
Instead, we treat file, files, formula, and mirror columns as forensic targets. At approval time we store lockedFileAssets (columnId, assetId, name, fileSize). On a file webhook, extractWebhookFileAssets normalizes monday's inconsistent payload keys (assetId ?? asset_id ?? file_id ?? id and clear_all: true) and diffs asset IDs:
const lockedIds = new Set(lockedForCol.map((f) => f.assetId));
const incomingIds = new Set(incomingFiles.map((f) => f.assetId));
const removedFiles = lockedForCol
.filter((f) => !incomingIds.has(f.assetId))
.map((f) => f.name || f.assetId);
const addedFiles = incomingFiles
.filter((f) => !lockedIds.has(f.assetId))
.map((f) => f.name || f.assetId);
if (removedFiles.length === 0 && addedFiles.length === 0) {
return { action: "ignore_echo" };
}
If anything changed, we acquire the lease, flip the record via CAS to status: "tampered" (isLocked: false), move the board status to "Tampered — Re-Approval Required", post buildFileTamperAlertHtml listing the exact added and removed filenames, and fire a tamper trigger.
Optimistic CAS Quorum (recordApprovalDecisionWithCas)
On a 2-of-3 quorum stage, two reviewers clicking Approve within 50ms will clobber each other under naive read-modify-write. recordApprovalDecisionWithCas (approvals.ts) runs a bounded retry loop (maxRetries = 6): read ItemApprovalDoc and version, run assertCanApprove (blocking viewers, unassigned guests, self-approval, and duplicate votes), clone stages via structuredClone, advance sequential or contiguous parallel stages, and commit with saveApprovalCas(candidateDoc, current.version). MongoDB executes findOneAndUpdate({ _id: key, version: expectedVersion }, { $set: ..., $inc: { version: 1 } }). On ConcurrencyConflictError, the loop reloads and retries cleanly.
HMAC-SHA256 Audit Receipts in monday Updates
Board owners can edit or delete plain "Approved" comments in monday Updates. On every vote, we hash sorted columnId:assetId:name:fileSize into filesDigest, sign accountId:itemId:receiptId:actorUserId:decision:timestampIso:canonicalDigest with HMAC-SHA256 to print an 8-character shortVerifyCode inside an HTML-escaped table (buildApprovalReceiptHtml), then hash and sign the full rendered HTML (htmlDigest / hmacSig).
Later, verifyReceiptsIntegrity checks live Updates and marks each receipt VERIFIED, TAMPERED, DELETED, or PENDING_SYNC (with a 15-second grace window for fresh writes). Because monday's HTML sanitizer sometimes rewrites tags or whitespace, it falls back to comparing SHA-256 of normalizeReceiptText(found.body) against textDigest before flagging TAMPERED.
These patterns run in production inside ApproveFlow, our multi-stage approval and tamper-protection app for monday.com. If you want to quantify how much cycle time stalled sign-offs cost on your boards, try the free Approval Bottleneck Calculator.
Top comments (0)