cultnet-ts: write_not_authorized blank-reason check is C# IsNullOrWhiteSpace
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 5m11s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 36s

Review: trim() differs from string.IsNullOrWhiteSpace on U+0085 and U+FEFF; use the
package's isNullOrWhiteSpaceCSharp and pin both in the test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-07 19:36:32 +00:00
commit 2016ad7457
2 changed files with 5 additions and 1 deletions

View file

@ -1,3 +1,4 @@
import { isNullOrWhiteSpaceCSharp } from "./cultmesh-authority";
import type { DocumentPayload } from "@gamecult/cultcache-ts/document";
import Ajv2020, { type ValidateFunction } from "ajv/dist/2020.js";
@ -211,7 +212,7 @@ export function cultNetTextError(error: string): CultNetErrorMessage {
export function cultNetWriteNotAuthorizedError(recordKey: string, reason?: string | null): CultNetErrorMessage {
return {
schemaVersion: "cultnet.error.v0",
error: reason && reason.trim() ? `write_not_authorized: ${reason}` : "write_not_authorized",
error: typeof reason === "string" && !isNullOrWhiteSpaceCSharp(reason) ? `write_not_authorized: ${reason}` : "write_not_authorized",
routingHint: null,
code: "write_not_authorized",
details: { field: "recordKey", value: recordKey, asOf: null, current: null },

View file

@ -93,4 +93,7 @@ test("a write_not_authorized refusal with no reason, or a blank one, says only t
assert.equal(cultNetWriteNotAuthorizedError("k").error, "write_not_authorized");
assert.equal(cultNetWriteNotAuthorizedError("k", " ").error, "write_not_authorized");
assert.equal(cultNetWriteNotAuthorizedError("k", null).error, "write_not_authorized");
// C# string.IsNullOrWhiteSpace counts U+0085 as white space and not U+FEFF; JS trim() disagrees on both.
assert.equal(cultNetWriteNotAuthorizedError("k", "\u0085").error, "write_not_authorized");
assert.equal(cultNetWriteNotAuthorizedError("k", "\ufeff").error, "write_not_authorized: \ufeff");
});