Repository navigation
Description
What is missing today
validateCard in latch.mjs:119 checks that every capability of a card declares a usable input schema. The check is at latch.mjs:154:
validateInput({}, capability.input || {}, `${at}.input`).forEach((error) => {
if (error.includes("must be object")) errors.push(`${at}.input must be an object schema`);
});It never fires. validateInput produces the message must be object only when the declared type is exactly object, and a schema whose type is object always matches the empty object that is validated against it, so no error is produced for it. A schema whose type is string produces must be string, a schema whose type is array produces must be array, and a schema with no type produces no error at all. None of those messages contain must be object.
The consequence is that the card is accepted with a capability input schema that is not an object schema. A card with "input": {"type": "string"} passes validateCard, so latch validate card.json prints {"valid": true, ...} and createLatchServer starts. At request time process validates the input against that same schema (latch.mjs:400), so an ask with "input": "hello" passes validation and the provider handler receives a string where the protocol says the input is an object. The card check and the request check agree with each other and both disagree with the protocol.
SPEC.md defines the field as an object: the envelope table in section 3 lists input as "Capability input object", and the capability schema in section 2 is documented as an object schema. The error text in the code says the same thing: must be an object schema.
What done means
validateCardrefuses a card whose capability declares an input schema that does not describe an object. The error names the capability id and the declared type, and the card is refused withinvalid_cardand HTTP 422 as today.- The check is made on the schema itself, not on the text of an error message produced by validating
{}. A schema whosetypeisstring, a schema whosetypeisarray, and atypelist that does not containobjectare all refused. - A capability input schema with no declared
typekeeps its current behaviour and is not refused by this change. - The cards that ship with the repository still validate: the demo provider card in
latch.mjs, the card written bylatch init(latch.mjs:986) andproviders/php/latch.json. askandquotestill validate the input against the capability schema at request time and still refuse a bad input withinvalid_inputand HTTP 422.npm testpasses, with one test for a card whose capability input schema is not an object schema.node --check latch.mjspasses andnode latch.mjs demo --trace examples/trace.jsonstill produces the same trace.
Boundary
- Zero runtime dependencies. Node.js 20+ and the standard library are enough.
- No change to the wire contract, to the envelope, to the error codes or to the HTTP status codes.
- No change to the request validation in
validateInput; the change is in the card check. - No network call, no telemetry, no account, no service, and no change to the demo provider behaviour.
- Do not add vendor links or endorsements to the documentation, and do not trade a documentation change for this fix.
Activity
Balanov commentedon Nov 15, 2026
Thank you for the report, and for the fix. @ShahadatTest opened pull request #2 and it is merged: the card validation now reads the declared input schema type instead of matching an error message, so a card whose input is not an object schema is refused with invalid_card and HTTP 422, naming the capability and the declared type. SPEC.md says the same thing now. It ships in latch 0.2.1.
Thank you for the report and for the fix.