Applies to v1.3.18

AISI — push and queue notifications

By default every AISI sync polls: it asks its storage for changes on a schedule (every five minutes unless the sync says otherwise). Polling always works, needs nothing beyond the storage connection, and misses nothing. A change waits, at most, for the next check.

Some storage services can also tell AISI when something changes, so the change is picked up within seconds:

Mode Storage What it needs
Push Microsoft Graph (OneDrive, SharePoint) Webhooks enabled on the deployment. AISI registers its address with Microsoft.
Push Google Drive Webhooks enabled on the deployment. AISI registers its address with Google.
Push MinIO Webhooks enabled on the deployment, a Webhook token on the connection, and a webhook target that a MinIO administrator configures
Queue Amazon S3 (and SQS-compatible services) An SQS queue receiving the bucket's event notifications, named on the sync. No webhooks needed.

A notification is only ever a hint. It makes AISI check the storage now instead of later; AISI then reads the storage exactly as a poll would. A notification that never arrives costs time, never a change: every push sync also runs a slow safety poll (hourly by default), and a queue sync compares the whole folder on the same schedule. A forged notification costs one extra check and changes nothing.


1. Enabling webhooks

Push needs the deployment to receive HTTPS calls from the internet. Queue mode does not, and works without this section.

Set the same values on the Portal API and the Jobs Worker:

Setting Value
AISI__WEBHOOKS__ENABLED true
AISI__WEBHOOKS__PUBLICBASEURL The public https origin vendors call, for example https://hooks.example.com. No path, query or credentials.

The Portal API receives notifications and decides whether Push is offered. The worker registers each sync's address with Microsoft and Google and removes the registrations when webhooks are switched off. If the two disagree, syncs ask for push that never arrives, or arrives and is refused.

The remaining settings (MAXBODYBYTES, PERMITLIMIT, WINDOW) and the Gateway's limits are in the configuration reference. The defaults suit most deployments.

What to expose, and only that

Vendors call one path through the Gateway:

POST {PUBLICBASEURL}/portal/hooks/aisi/{id}

Publish only this path to the internet. If your reverse proxy or firewall publishes by path, allow /portal/hooks/aisi/ and nothing else under /portal. The Gateway route behind it is anonymous, because vendors cannot sign in. Each notification is checked against a per-sync secret instead.

What the route does:

  • Each sync has its own address. The {id} is random and unrelated to any record in the platform, so an address reveals nothing and cannot be guessed.
  • Every refusal looks the same. An unknown address, a missing or wrong secret, an unreadable body and webhooks switched off all get the same empty 404. A caller cannot probe which addresses exist.
  • Nothing is stored. The body is checked and dropped. It is never stored, logged or forwarded.
  • It is bounded. Bodies over 64 KiB are refused with 413. The rate is limited per client address at the Gateway, and per client address and sync address in the Portal API, so one busy sync cannot crowd out another.
  • It needs a valid certificate. Microsoft and Google require HTTPS with a publicly trusted certificate on PUBLICBASEURL. A self-signed certificate makes them refuse to register.

With webhooks enabled, each sync's change-notification choice offers Push where the storage supports it. With them disabled, Push stays listed but disabled, with the reason.


2. Choosing a mode on a sync

A sync's Change notifications setting (in the sync wizard, and on the Change notifications tab of the sync's page) offers:

  • Automatic (the default). Push wherever it needs no setup at the storage service: Microsoft Graph and Google Drive, when webhooks are enabled. Polling everywhere else, including every S3 connection. Choose this unless you have set up MinIO webhooks or an SQS queue.
  • Polling. Never push, whatever the deployment offers.
  • Push. Push, and say so if it is unavailable.
  • Queue. Read an SQS queue (S3 connections only).

A mode that needs setup at the storage service shows Set up at the storage service with what to do when you choose it. You may save first and configure the storage after. Until the setup is done, the sync polls and the Overview tab of its page says what is missing (see §5).

Poll every (minutes) keeps a meaning in every mode:

  • while polling, it is how often the storage is checked;
  • in Queue mode, it is how often the queue is read;
  • with Push, it is the fallback used while notifications are unavailable.

3. What each storage needs

Microsoft Graph (OneDrive, SharePoint)

Nothing beyond webhooks and the connection itself. AISI subscribes to the drive when the sync starts, renews the subscription before it expires (Microsoft allows just under 30 days), and answers Microsoft's address check.

  • The address must answer within seconds. Microsoft checks it before granting the subscription. If PUBLICBASEURL does not reach the Gateway from the internet, the subscription is refused and the sync's page names the address to check.
  • The app needs Files.Read.All, as for reading. It needs no permission to subscribe.
  • One subscription per drive and app registration. Microsoft refuses a second subscription on the same drive from the same app. Two syncs on one drive through one connection therefore get push for one of them; the other polls, and its page says why. Use separate app registrations if both must have push.
  • Changes anywhere in the drive wake the sync, because Microsoft only subscribes to a whole drive. A change outside the sync's folder costs one check that finds nothing.

Google Drive

Nothing beyond webhooks and the connection itself. AISI opens a watch channel on the drive's change feed when the sync starts. Channels last at most a week and cannot be extended, so AISI opens a new one before the old one lapses.

  • The address needs HTTPS with a publicly trusted certificate. Google refuses any other, and the sync's page names the origin.
  • The Drive API must be enabled in the service account's Google Cloud project. A refusal says so.
  • Changes anywhere in the drive wake the sync, for the same reason as Microsoft Graph.

MinIO (Push)

MinIO calls a webhook target that a MinIO administrator configures; an S3 access key cannot create one. Set up one target per sync.

  1. On the AISI connection, set Webhook token: a random value of at least 16 characters, without spaces. For example, openssl rand -hex 24 generates one.

  2. On the sync, choose Push and save. Open the sync's page: on its Overview tab, Webhook address shows the address to configure, with a Copy button.

  3. In MinIO, add a webhook target with that address as its endpoint and the connection's webhook token as its auth_token, then send the bucket's object events to it. For the sync's folder only, use the folder as a prefix:

    mc admin config set myminio notify_webhook:aisi-contracts \
      endpoint="https://hooks.example.com/portal/hooks/aisi/3pV…" \
      auth_token="<the connection's webhook token>"
    mc admin service restart myminio
    mc event add myminio/documents arn:minio:sqs::aisi-contracts:webhook \
      --event put,delete --prefix contracts/
    

Notes:

  • MinIO sends the token as Authorization: Bearer …. A notification without it is refused, like an unknown address.
  • The notification's content is not used. It only says that something changed. AISI then lists the folder, as a poll would.
  • Rotating the token: change it on the connection and in each of the connection's MinIO targets. Saving the connection makes its syncs use the new token at once. Notifications carrying the old one are refused until MinIO's targets are updated, and the safety poll covers the gap.
  • Deleting the sync leaves its MinIO target in place. Remove it in MinIO. AISI refuses its notifications from then on.

Amazon S3 (Queue)

S3 can publish a bucket's events to an SQS queue. AISI reads the queue in place of listing the bucket on every check. On a large bucket, that is much cheaper than polling.

  1. Create an SQS standard queue in the bucket's region. FIFO queues cannot receive S3 events. One queue per sync: reading a message removes it, so two syncs on one queue would each miss what the other read. To feed several syncs from one bucket, publish to an SNS topic and subscribe one queue per sync to it.
  2. Allow S3 to publish to it, in the queue's access policy (principal s3.amazonaws.com, action sqs:SendMessage, condition aws:SourceArn = the bucket's ARN).
  3. Add an event notification on the bucket: events s3:ObjectCreated:* and s3:ObjectRemoved:*, the sync's folder as the prefix, destination the queue.
  4. Give the connection's access key sqs:GetQueueAttributes, sqs:ReceiveMessage and sqs:DeleteMessage on the queue.
  5. Approve the queue's host (for example sqs.eu-west-1.amazonaws.com) in the tenant's outbound allowlist, under the purpose AISI SQS queue endpoint.
  6. On the sync, set SQS queue URL to the queue's URL, choose Queue and save.

Notes:

  • Messages are only hints. For every object a message names, AISI asks the bucket what is actually there. A forged or stale message costs one lookup and changes nothing.
  • Nothing is lost on a crash. A batch's messages are deleted from the queue only after its changes are saved. If saving fails, they come back and are checked again.
  • A queue emptied by someone else is covered. The full comparison on the safety schedule catches whatever its messages carried.
  • Deleting the sync leaves the queue and the bucket notification in place. Remove them in AWS.

4. How to tell it is working

Open the sync (AISI → Syncs, select the sync and choose Open sync); its Overview tab shows:

Where What it should show
Change notifications badge (the grid's Changes column and the Overview tab) Push or Queue, not Polling every N min
Last notification A recent time after a change at the source. None received yet means nothing has reached AISI.
Changes applied → notifications received Grows with each notification
Notifications renew by (Microsoft and Google) A date in the future; AISI renews before it

Quick test: change a file in the sync's folder and watch Last change seen. It should move within seconds. With polling, it moves at the next check.

A newly saved sync polls first. Saving tells the worker to set up push or queue at once, so a badge reading Polling for the first moments after saving is expected.

Logs and metrics, for whoever runs the deployment:

  • aisi_webhook_requests_total{outcome}, on the Portal API, counts every request to the route by outcome:

    • signal and lifecycle: accepted notifications;
    • handshake and acknowledged: Microsoft's address check and Google's channel opening;
    • rejected: a known address without its secret;
    • unknown: an address AISI never issued;
    • disabled: webhooks switched off;
    • unpublished: the message broker was unavailable, and the vendor will retry.

    rejected or unknown with no signal usually means a wrong token or a stale address (a deleted sync's) in the storage's configuration.

  • A notification that names a known sync but lacks its secret is logged as a Warning naming the sync. A request to an unknown address is logged at Debug only, because internet scanners send them all the time.

  • aisi_subscription_degraded_total{provider}, on the worker, counts degradations (below).


5. When notifications are unavailable

If AISI cannot set up or keep a sync's push or queue notifications, the sync is degraded:

  • It polls at its own interval, so nothing is missed, only noticed later.
  • Its badge reads Push — degraded to polling or Queue — degraded to polling, and its state is Degraded.
  • The Overview tab of the sync's page explains it: why (the message names what to fix), since when, how many attempts have failed, and when AISI tries next.
  • It appears under Syncs needing attention on the AISI overview.
  • AISI notifies once when the degradation starts and once when it ends, and records both in the audit log.

AISI retries on its own: first after the upkeep interval (five minutes by default), then at doubling intervals up to six hours. Saving the sync, or its storage connection, retries at once. So after fixing the cause (a token, a permission, an allowlist entry), save the connection rather than wait.

The page says Fix
Push needs a public callback URL Enable webhooks (§1), or choose Automatic or Polling.
…could not reach the webhook address… / …is not HTTPS with a publicly trusted certificate… PUBLICBASEURL must reach the Gateway from the internet, over HTTPS with a public certificate.
…another sync's subscription… (Microsoft Graph) One subscription per drive and app registration (§3).
Enable the Drive API… Enable it in the service account's Google Cloud project.
…answered a subscription request without a usable expiry (Microsoft Graph) / …answered a watch request without a usable expiry (Google Drive) Nothing to fix at your end: AISI never keeps a subscription it could not renew in time, so it polls and asks again at the next attempt. If it persists, check the service's status.
Bind the connection's webhook token… Set Webhook token on the connection (MinIO).
Name the SQS queue… / The queue URL must be… Set the sync's SQS queue URL to a standard queue's URL.
The queue does not exist / SQS refused the access key… Check the queue URL and the key's sqs: permissions (§3).
…is not approved in this tenant's outbound allowlist for S3 event queues Approve the queue's host, purpose AISI SQS queue endpoint.

When the cause is fixed, the next attempt succeeds, the sync returns to Push or Queue, and the page's warning goes away.

Switching webhooks off makes every push sync poll. Syncs set to Automatic do so quietly; syncs set explicitly to Push are degraded and say why. AISI removes its Microsoft and Google registrations. MinIO targets and SQS queues are yours, and stay as they are.