Skip to content

Learned API schema ​

Symptoms of the learned API schema: schemas the product builds from observed traffic and checks in block or detect mode.

No schema suggestion for an endpoint that receives JSON ​

  • Cause: the endpoint is not ready yet (samples, clients, duration or confidence below the thresholds); learning or body learning is off (learning.enabled, learning.bodies); the requests are not clean (another module flagged them, or the upstream answered 400 or more); or the content type is not JSON (application/json or +json), so the body is not parsed.
  • Check: the learned model's endpoint detail (the status and the confidence factor that limits it); the learning counters per result; the content type of the requests.
  • Fix: wait for more traffic, lower the thresholds for a test application, or fix the client's content type.

A legitimate request is refused with api.learned.body ​

  • Symptom: the event names a JSON pointer and a constraint ("/qty: 120 is above the maximum 112", or "not one of the 3 allowed values").
  • Cause: the learning window did not see that kind of value (a new product range, a rare plan name), or the application changed after the schema was approved.
  • Check: the event's pointer, value and message against the schema (waap api list get -app A learned_schemas); the learned model's evidence for the field.
  • Fix: edit the field in the schema (it then becomes source: manual), or reject it and relearn. While you decide, set api.learned.mode: detect, or add an exception for api.learned.body with a json: field at that pointer.

api.learned.unknown_field for a field the application accepts ​

  • Cause: the field is new, or too rare during learning to be included. A field that was never seen is unknown; fields seen even rarely are known.
  • Check: whether the field is in the schema's properties at the event's pointer.
  • Fix: add the field to the schema (any value, such as {}), or set additional: allow on that object. Fields are only logged unless unknown_fields: refuse or additional: refuse is set.

A schema with additional: allow I did not write ​

  • Cause: the object had more field positions than learning keeps (256 per endpoint and direction), or was nested deeper than 16 levels, so unknown fields could not be told apart. The endpoint's evidence shows an overflow count.
  • Fix: none needed. Write the object's fields by hand if they matter.

The schema is not applied on an endpoint that has one ​

  • Cause: an imported OpenAPI description describes the operation (the description always wins); or the request's body is not JSON; or the endpoint template does not match the path (method or literal segments); or learned_schemas is empty, which turns the check off whatever api.learned says.
  • Check: the trace (api_schema step) and the request's matched operation; the template against the path.
  • Fix: remove the operation from the description, or change the template.

Answers are never learned or never checked ​

  • Cause: answers are read only when they are JSON, below 400 (for learning) or of a listed status (for checking; empty means 2xx). Learning reads at most 256 KiB and checking reads up to policy.response.max_body. The answer must not be truncated, must be inside the response scope (policy.response paths and content types), and must not be compressed with an encoding the product does not decode (br, zstd). Learning also samples at response_sample_rate. Answer learning is off by default (learning.responses); answer checks are off with api.learned.responses: off.
  • Check: the trace's response_body steps (a skipped step names the reason); the answer's Content-Type, Content-Length and Content-Encoding.
  • Fix: turn the setting on, widen the response scope, or raise the sample rate.

api.learned.response events but nothing is refused ​

  • Cause: by design, answer checks are detect only in this release. They show answers that changed shape or carry fields they did not carry before, which can be a data leak.
  • Fix: review the field. Mask it with data leak protection if it should not leave the application.

Approving a schema suggestion is refused (management) ​

  • Symptom: approving a learned schema suggestion is refused.
  • Cause: the schema is manual (a hand-written entry covers the endpoint), it is rejected, the endpoint has no new suggestion, or the policy changed since the suggestions were read (base_version).
  • Check: waap api learned suggestions -app NAME shows the status of each; the Learned schema tab in the console shows the same.
  • Fix: edit a manual schema under "Schemas in the policy"; restore a rejected one first (waap api learned restore); then read the suggestions again and retry.

The OpenAPI export answers 404 ​

  • Symptom: the OpenAPI export of learned schemas answers 404.
  • Cause: the policy has no schemas, and without -suggested nothing is exported.
  • Fix: approve a suggestion or add a schema, or export with -suggested (in the console, "Include suggested schemas").