Skip to main content
Version: 1.9.0

Legacy document ingest

Overview​

POST /api/documents and POST /api/files/upload/ reject a create when Bcyip-Agent is missing. A document create also requires fileId or idUpload, except when the agent is iptower. The header values are stored on the document as auto-attributes.

How it works​

requireAgentHeader returns 400 when Bcyip-Agent is missing or blank. Any non-empty value is accepted. The value is not checked against agent_codes.

validatePostDocumentCreate then requires fileId or idUpload unless the trimmed header is iptower (case-insensitive). When a reference is present, assertLinkableRemoteFile checks that the RemoteFile exists, belongs to the job, matches the document hash, and is not already linked. The document row is removed if that check fails.

buildIngestAutoAttributes writes bcyip:agent and bcyip:agent-version from the headers. A blank header is omitted. The values are not read from users.agent or apitokens.agent.

Key files​

  • app/util/documentIngest.js — Header guard, fileId rule, auto-attributes
  • app/routes/documents.js — Guard and attributes on document create
  • app/routes/files.js — Guard on POST /files/upload/
  • app/routes/files-big.js — Same guard on the upload API
  • app/services/documents.js — RemoteFile ownership, hash, and link checks
  • app/database/schema/document.js — autoAttributes on the document

Technical decisions​

  • Tower may create a document without a file. Every other agent must link an upload.
  • The header is required for Tower too. Only the file reference is optional for iptower.
  • Header text is stored as sent (trimmed). It is not replaced by the token's agent field.

Known issues​

  • The document is inserted, then deleted, when the RemoteFile check fails.

Next steps​

  • Reject the create before the insert when fileId is invalid