anomalyco/sst · error · VisibleError
The `namespaceId` property must be a positive integer.
Error message
The `namespaceId` property must be a positive integer.
What it means
`sst.cloudflare.RateLimit` requires `namespaceId` to be a positive integer because it maps to a Cloudflare rate-limit binding namespace id (a numeric string at the API boundary). Non-integer, zero, or negative values are rejected at synth time.
Source
Thrown at platform/src/components/cloudflare/rate-limit.ts:98
constructor(
name: string,
args: RateLimitArgs,
opts?: ComponentResourceOptions,
) {
super(__pulumiType, name, args, opts);
const namespaceId = normalizeNamespaceId();
const limit = output(args.limit);
const period = normalizePeriod();
this._namespaceId = namespaceId;
this._limit = limit;
this._period = period;
function normalizeNamespaceId() {
return output(args.namespaceId).apply((namespaceId) => {
if (!Number.isInteger(namespaceId) || namespaceId <= 0) {
throw new VisibleError(
"The `namespaceId` property must be a positive integer.",
);
}
return namespaceId.toString();
});
}
function normalizePeriod() {
return output(args.period).apply(toSeconds);
}
}
/**
* A unique identifier for the rate limit namespace.
*/
public get namespaceId() {
return this._namespaceId;View on GitHub (pinned to a0bd20f762)
Solutions
- Set `namespaceId` to the positive integer id from your Cloudflare rate-limit binding configuration
- If sourcing from an env var, parse and validate: `Number.isInteger(Number(id)) && Number(id) > 0` before passing
- Remove placeholder values like 0 left from templates
Example fix
// before
new sst.cloudflare.RateLimit('RL', { namespaceId: 0 });
// after
new sst.cloudflare.RateLimit('RL', { namespaceId: 42 }); Defensive patterns
Strategy: validation
Validate before calling
const id = Number(process.env.RATE_LIMIT_NS_ID);
if (!Number.isInteger(id) || id <= 0) throw new Error(`namespaceId must be a positive integer, got: ${id}`);
new sst.cloudflare.RateLimit('RL', { namespaceId: id }); Type guard
function isPositiveInt(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v > 0;
} Try / catch
// synth-time VisibleError
try {
const rl = new sst.cloudflare.RateLimit('RL', { namespaceId: cfg.namespaceId });
} catch (e) {
console.error('Invalid namespaceId:', e.message);
} Prevention
- Copy namespace ids exactly from Cloudflare (numbers only)
- Validate any env-var-sourced id with Number.isInteger and > 0
- Never leave placeholder values like 0 in config
When it happens
Trigger: Passing `namespaceId: 0`, a negative number, a decimal like `1.5`, or a value that isn't a number at all (e.g. a string) to the RateLimit component's `args.namespaceId`.
Common situations: Hardcoded placeholder `0` left in config; copying a Cloudflare dashboard value that includes characters; constructing the id from env vars that resolve to undefined/NaN.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Invalid function definition for the "${name}" Function
- Cannot subscribe to the "${this.constructorName}" queue mult
- Invalid size ${size}
- Record name "${recordName}" is not a subdomain of "${domain}
- Cloudflare API error: %s
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/b7cd76eafbd31468.
Report an issue: GitHub.