Skip to content

M6-S1 — Integration surfaces inside: Functions, webhooks and connectors

Section titled “M6-S1 — Integration surfaces inside: Functions, webhooks and connectors”
ModuleM6 — Extension design
After this session you canExplain how a Function is provisioned and invoked, how an outbound call and a connector behave under failure, and judge an integration from that.
Time65 min with a facilitator · about 65 min on your own
Before you startM4-S2 (reaction runs) and M5-S4 (the threat-model method). Larkspur Dev this time, because it has the function builder: signed in as Rami Aziz, a terminal with Node.js 20+, npm, zip, curl and jq, and BASE set to your Larkspur Dev address and TOKEN to your Dev Larkspur Workbench token (the workbench explains how).
Go deeperFunctions: run your own code · Webhooks and integrations · Functions in a multi-tenant deployment · Grafana dashboards

◆ Orientation (1 min) — The doors out of the designer

Section titled “◆ Orientation (1 min) — The doors out of the designer”

M6 is where you decide how to extend the platform, and you cannot judge an extension point until you know how it behaves inside. You wrote, deployed and called Functions in ACE M4-S1, and sent webhooks with Call API in ACE M6-S1. This session opens both: the life of a Function from upload to teardown, the three ways the platform calls it, and the bounds every outbound call runs inside. You follow one invocation end to end on Larkspur Dev, and end with a worked scenario on a third surface, the Grafana data source. M6-S4 then puts every surface on one map.

▤ Concept (8 min) — A Function’s life, an outbound call’s bounds

Section titled “▤ Concept (8 min) — A Function’s life, an outbound call’s bounds”

A Function is a record: an entry of the platform’s Functions entity holding its name, its type (reaction custom action, standalone validator, value validator or interceptor), its scope (system, module or entity), the uploaded ZIP, and a provisioning block that the platform fills in later. Everything else follows from that, because the functions service reacts to the record’s events:

sequenceDiagram
  participant D as Data service
  participant F as Functions service
  participant P as Provisioner (build queue)
  participant K as Serverless runtime
  D->>F: Function record created or its ZIP replaced
  F->>P: provision request (ZIP location, name, namespace, environment)
  P-->>F: accepted (queued)
  P->>F: callback: Provisioning
  P->>K: build the image and deploy it, cluster-local
  P->>F: callback: Provisioned, URL, parameters
  F->>D: patch the record's provisioning block

What to notice: the platform learns the function’s address only from the provisioner’s callback. Until then the record exists but nothing can call it.

The stages, and what to look at when one goes wrong:

  • Create a record with a ZIP → a provision request. If no provisioner is configured, nothing happens at all: the status never leaves its initial value and no error is shown. That is the first thing to rule out on a new environment.
  • Edit the record → a re-provision only if the ZIP changed. A new name or description changes nothing in the runtime.
  • The provisioner is its own service with a build queue. It downloads the ZIP, reads func.yaml and params.yaml, forces the function to be cluster-local (no public address), reports Provisioning, then builds and deploys with the serverless runtime’s tools. It classifies build errors: a recoverable one ends as Build failed with the message in Provisioning Error; an unrecoverable one is not retried.
  • The callback sets the status, the Function URL, the deployed name and the parameter list read from params.yaml. Only now can a reaction offer the function.
  • Archive the record → the deployment is deleted.

Three 1.10 facts shape design. Per tenant: in a multi-tenant deployment every tenant’s functions run in their own namespace, fn-<tenant id>, with their own image path, so two tenants’ functions never collide. Deployed name: the platform derives it from the record, the slug of its normalized name plus the first twelve characters of the record’s id, so the name in your func.yaml no longer matters and two records that upload the same ZIP no longer overwrite each other. Environment: the runtime receives APP_ID (the tenant) and OSOS_API_BASE_URL (the tenant’s public API address) and nothing else from the platform: on the 1.10 line a Function has no credential of its own and no secret store. A Function that needs data should receive it as parameters.

A Function runs in the serverless runtime, not inside the platform. Its isolation is the runtime’s: there is no in-process sandbox, so whoever can upload a ZIP can run code in the cluster. That is why managing Functions needs a system Admin.

CallerPathWhat it sendsHow the answer is read
A reaction’s Execute Function actionThe reaction service posts straight to the Function URLA CloudEvent whose data is {context, parameters}: the run’s context and the parameters the builder mappedAny answer counts as the action having run; your success flag travels in the output for chained reactions
A validator, before a saveThe data service calls the functions service, which checks the function is active, provisioned and has a URL, then posts{dataEntry, existingEntry} or {value}{success, errors}; each error code is looked up in the function’s own error catalogue for the message
Your own programPOST /api/functions/v1/<function id>/execute, with a credential since 1.10Your JSON bodyThe function’s JSON, or {success: false, error}

Two answer rules hold everywhere. A response sent as plain text is treated as an error, and a body that does not parse as JSON becomes {success: false, error}. The data service retries a call to the functions service when it fails with anything but a client error, so a validator must be safe to run twice.

Interceptors are Functions bound to a path and method, run before a matching request reaches the platform; they may rewrite the request or answer it. They fail open: an interceptor that fails is skipped and the request continues. Never make an interceptor the only control that protects something.

Call API runs in the reaction service as a server-side HTTP client driven by a builder’s configuration, so it is bounded on every axis:

BoundRule
Destinationhttp or https only; private, loopback, link-local and other reserved addresses are refused, checked when the host name resolves and again on every redirect (five at most), unless the operator allows that destination
TimeOne deadline for the whole exchange, 30 seconds by default
SizeRequest and response bodies, and what is recorded, at most 10 MiB
HeadersThe header template is read as JSON first and values filled in afterwards, so a value can never add a header; the platform’s own header names are refused when the reaction is saved
Protected valuesA call whose address, headers or body would carry a masked sensitive value fails instead of sending the mask
SuccessA 2xx answer; anything else, or a refusal, is a failed action

Every run records the request and the response in the run’s history, with credential headers and anything marked Redact in history stored as ****. The platform does not sign outbound requests. The receiver must authenticate each call itself, with a secret the builder sends and the history redacts.

Connectors sit on the same machinery. Notify Zapier posts through the integrations service to the hooks that subscribed; you learned its caveat in ACE. The Grafana data source is the reverse direction, described in the worked scenario.

▶ Guided demo (8 min) — A Function record, read as data

Section titled “▶ Guided demo (8 min) — A Function record, read as data”

Starting state. Larkspur Dev; the seed’s function spare-part-price (Reaction Custom Action, scope Asset Maintenance) is provisioned.

  1. Open Administration › Applications › Functions and open spare-part-price. Read its Status, its Function URL and its parameters.
  2. Read the host part of the URL: the deployed name is the slug of the function’s name, a hyphen and twelve characters of the record’s id, then the namespace.
  3. Read the record through the API: curl -s "$BASE/api/functions/v1/MODULE?scopeId=<Asset Maintenance id>" -H "x-app-token: $TOKEN" | jq '.result[] | {id, name, normalizedName, params: .parameters}'. The list holds only provisioned, active functions, so it carries no status: each item is the id, the name, the normalized name and the parameters.
  4. Change the function’s description and save. Status stays Provisioned and the URL is unchanged: no rebuild.
  5. Open Data Entities › Spare Parts › Reactions and add a reaction with Execute Function: spare-part-price is offered, with its two parameters. Cancel without saving.

Screenshot pending The spare-part-price function record with Status Provisioned and a Function URL whose host carries the deployed name and namespace What to notice: the address is cluster-local; nothing outside the cluster can reach it, which is why it needs no protection of its own.

PracticeChoose one answer.

On a new environment, a Function was created with a valid ZIP an hour ago. Its status has never changed and Provisioning Error is empty. What do you check first?

  1. Explanation for A

    ✗ Incorrect

    Not this one: a bad project ends as Build failed with a message; the name in func.yaml no longer matters on 1.10. See from record to running service.

  2. Explanation for B

    ✓ Correct

    Correct: with no provisioner configured, creating a Function is a silent no-op, so the status never moves and no error appears. See from record to running service.

  3. Explanation for C

    ✗ Incorrect

    Not this one: provisioning follows the Function record, not the reactions that will call it. See from record to running service.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A Function must read the current exchange rate table from a record in the suite. On the 1.10 line, what is the design that works?

  1. Explanation for A

    ✗ Incorrect

    Not this one: a function’s own token is not part of the 1.10 line; the runtime receives only the tenant and the API address. See from record to running service.

  2. Explanation for B

    ✓ Correct

    Correct: on 1.10 a Function has no credential of its own, so data reaches it as parameters the builder maps. See three ways a Function is called.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a secret in the source travels with every copy of the ZIP and with every export. See from record to running service.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A value validator answers Invalid serial number as plain text when a serial is wrong. What does the person saving the record see?

  1. Explanation for A

    ✗ Incorrect

    Not this one: a plain-text answer is treated as an error of the function, not as a validation result. See three ways a Function is called.

  2. Explanation for B

    ✓ Correct

    Correct: validators must answer {success, errors} with codes from the function’s catalogue; text is read as a function error. See three ways a Function is called.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the function’s answer could not be read as a validation result, so it is an error. See three ways a Function is called.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

⛏ Lab (34 min) — Follow one invocation end to end

Section titled “⛏ Lab (34 min) — Follow one invocation end to end”

Goal. Deploy a small Function that reports what it receives, call it from a reaction and from your own program, and read every stage from the record, the run history and the API.

Before you start. Larkspur Dev, Rami Aziz. An empty working folder in your terminal. The project files are the same five you wrote in ACE M4-S1, so only the handler is shown in full.

  1. Create the project echo-context with func.yaml, params.yaml, package.json and tsconfig.json exactly as in ACE M4-S1, with the name echo-context and these parameters in params.yaml:

    version: "1"
    parameters:
    - name: part
    - name: quantity
  2. Write src/index.ts:

    import { Context } from 'faas-js-runtime';
    const handle = async (context: Context) => {
    const body = (context.body ?? {}) as Record<string, unknown> & { data?: Record<string, unknown> };
    const input = (body.data ?? body) as { context?: Record<string, unknown>; parameters?: Record<string, unknown> };
    return {
    success: true,
    message: 'echo',
    result: {
    received: Object.keys(input),
    contextKeys: Object.keys(input.context ?? {}),
    parameters: input.parameters ?? null,
    tenantSet: Boolean(process.env.APP_ID),
    apiBaseSet: Boolean(process.env.OSOS_API_BASE_URL),
    },
    };
    };
    export { handle };
  3. Build and test locally (npm install, npm run build, npm start, then one curl with {"parameters":{"part":"x","quantity":1}}), stop it, and zip it without node_modules and build.

  4. In Functions, select Add Function: name echo-context, Reaction Custom Action, scope module Asset Maintenance, the ZIP. Save.

  5. Reload until Provisioned. Note the time it took and the Function URL’s deployed name.

  6. On Spare Parts, add the reaction Echo on update: On Entry Updated, Execute Function echo-context, part mapped to Name, quantity mapped to Stock. Save.

  7. Edit the spare part Mechanical seal 40 mm and change Stock to 12.

  8. In Reaction Logs, open the run. In the output’s result: received lists context and parameters; parameters shows the name and 12; tenantSet and apiBaseSet are true.

  9. Read contextKeys: the run’s context, which a Function can read without any credential.

Screenshot pending Reaction Logs output of the Echo on update run, with received listing context and parameters, the mapped parameters, and both environment flags true What to notice: the Function sees the run’s context and the mapped parameters, and nothing that would let it call the platform as anyone.

  1. Call it from your own program:

    Terminal window
    curl -s -X POST "$BASE/api/functions/v1/<echo-context id>/execute" \
    -H "x-app-token: $TOKEN" -H 'Content-Type: application/json' \
    -d '{"parameters":{"part":"from-curl","quantity":3}}' | jq

    The answer is the function’s JSON: received lists only parameters, because you sent no context. This POST is the one exception to the workbench’s GET-only rule: echo-context reads and writes nothing.

  2. Call it again without the token. The gateway refuses it.

  3. Change message: 'echo' to message: 'echo v2', rebuild, re-zip and upload the new ZIP on the same record. The status goes to Provisioning and back; the URL is the same.

  4. Trigger step 7 again. The output shows echo v2.

  5. Archive echo-context. Call step 10 again: refused with a not-found or not-active error.

  6. Open the reaction Echo on update: its function is no longer available. Delete the reaction.

  7. Note in your table, for each stage, where you saw it: record, run history, API.

  8. Write one sentence on what an attacker who could upload a ZIP would gain, and which grant stops them.

Check.

  • echo-context reached Provisioned and its URL carries the deployed name.
  • The reaction’s run shows context and parameters, and both environment flags true.
  • The direct call returned the function’s JSON, and the call without a token was refused.
  • A new ZIP re-provisioned the function under the same URL.
  • After archiving, the function could not be called.
  • Your sentence names code running in the cluster and the system Admin needed to manage Functions.

Pass condition. Your stage table is complete, and the run-history output and the API answers match what the session predicts for each stage.

If something goes wrong

What you seeWhat to do
Provisioning for more than ten minutesAsk your training provider whether the function builder is running for your space; your local test in step 3 still stands.
Build failedRead Provisioning Error; usually func.yaml is not at the ZIP’s root.
received is empty in step 8You read context.body directly; keep the body.data ?? body line, because the payload may arrive inside the CloudEvent’s data.
The direct call answers {success: false, error}The function answered text or invalid JSON; run it locally again.
The direct call answers 403TOKEN holds a Larkspur Lab token, or the Larkspur Workbench user lacks its grant on Asset Maintenance in Dev; export the Dev token and ask your facilitator to check the grant.
Model answer

Creating the record queued a provision request; the provisioner reported Provisioning, built and deployed the function cluster-local under a name derived from the record, then called back with Provisioned, the URL and the two parameters from params.yaml. The reaction service posted a CloudEvent to that URL with {context, parameters}, so the output lists both, and the runtime had the tenant and the API address in its environment but no credential. Your own call went through the functions service, which checked the function was active and provisioned, and sent only your body. Uploading a new ZIP is the only edit that rebuilds, and the name, hence the URL, stays. Archiving deleted the deployment, so the execute call was refused and the reaction lost its function. Anyone who can upload a ZIP runs code inside the cluster, which is why only system administrators manage Functions.

◇ Worked scenario (3 min) — A Grafana board for the operations director

Section titled “◇ Worked scenario (3 min) — A Grafana board for the operations director”

Leila Amari wants an operations board in the company’s Grafana: spend by supplier, open work orders by plant, and non-conformances by supplier this quarter. A consultant proposes pointing Grafana at a read-only copy of the database. Decide at each step before you read on.

Step 1. Which surface? The platform ships a Grafana data source plugin. It executes saved platform objects only: a view’s rows, a saved query as a filter, or a statistic query’s result. It holds no credentials: every request goes through Grafana’s proxy with the signed-in viewer’s OAuth token, so the gateway and the permission engine decide exactly as for that person in the portal. The consultant’s database copy would bypass all of that, including the protected Bank Account. You choose the plugin.

Step 2. What must exist first? Every panel needs a view, because a view is what the gateway authorizes. Aggregates should be statistic queries, which compute in the platform instead of pulling rows into Grafana. Spend by Supplier already exists; you ask the builders for two more statistic queries and one view, named as a contract: the board depends on their names and shapes, so they go on the program’s list of things that must not change silently.

Step 3. The two settings that decide everything. The data source’s address must be the tenant’s real domain, because the gateway resolves the tenant and the space from the host; an internal cluster address fails. Forward OAuth Identity must be on; with it off, panels do not fail, they simply stop being personal, and every viewer sees whatever the proxy is allowed. You put both in the operations runbook with a test: two viewers with different access open the same panel and must see different rows.

Step 4. Under failure. If the identity service is down, panels fail for everyone, which is correct. If a builder renames a statistic query’s group field, the chart breaks quietly; the contract list from step 2 is what catches it in review.

The lesson: a reporting integration is judged by whose identity it carries and which contract it depends on, not by how quickly it shows a chart.

✓ Practice (6 min) — Outbound calls and judgement

Section titled “✓ Practice (6 min) — Outbound calls and judgement”
PracticeChoose one answer.

A builder’s Call API action posts to https://cmms.example.com/hooks. That name resolves to a public address, which redirects to http://10.20.0.7/hooks. What happens?

  1. Explanation for A

    ✗ Incorrect

    Not this one: destinations are checked again on every redirect, so the private address is caught. See an outbound call, bounded.

  2. Explanation for B

    ✓ Correct

    Correct: private addresses are refused on every hop, including after a redirect, unless allowed by the operator. See an outbound call, bounded.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the call never reaches the private address; it fails, and the failure is recorded. See an outbound call, bounded.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A CMMS team asks how to verify that a webhook really came from Larkspur’s platform. What do you tell them?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the platform does not sign outbound requests. See an outbound call, bounded.

  2. Explanation for B

    ✗ Incorrect

    Not this one: an address range is not proof of the sender, and it changes with the deployment. See an outbound call, bounded.

  3. Explanation for C

    ✓ Correct

    Correct: the receiver authenticates the call itself; the platform keeps the secret out of the run history. See an outbound call, bounded.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

A team protects a costly report endpoint with an interceptor Function that checks a quota and answers 429 when it is exceeded. During a runtime outage the interceptor cannot be reached. What happens?

  1. Explanation for A

    ✓ Correct

    Correct: an interceptor that fails is skipped and the request continues, so it must not be the only control. See three ways a Function is called.

  2. Explanation for B

    ✗ Incorrect

    Not this one: that would be failing closed, which interceptors do not do. See three ways a Function is called.

  3. Explanation for C

    ✗ Incorrect

    Not this one: nothing queues incoming requests; they are skipped past the failing interceptor. See three ways a Function is called.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

PracticeChoose one answer.

A reaction’s Execute Function action calls a Function that answers {"success": false, "message": "part not found"}. A chained reaction on Reaction Succeeded creates a purchase request. Does it run?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the action counts as run whenever the function answers; success travels in the output. See three ways a Function is called.

  2. Explanation for B

    ✓ Correct

    Correct: the run succeeded as far as the engine knows, so the chained reaction must check the output itself. See three ways a Function is called.

  3. Explanation for C

    ✗ Incorrect

    Not this one: validators answer to saves, not to reactions; this is a reaction custom action. See three ways a Function is called.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A Grafana data source was set up with Forward OAuth Identity off. What do viewers notice?

  1. Explanation for A

    ✗ Incorrect

    Not this one: panels keep working; they just stop being decided per viewer. See the Grafana board.

  2. Explanation for B

    ✓ Correct

    Correct: without the viewer’s token the per-viewer permission model silently stops applying. See the Grafana board.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the setting changes whose identity every request carries, for rows and statistics alike. See the Grafana board.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

↺ Recap (1 min) — Surfaces you can judge

Section titled “↺ Recap (1 min) — Surfaces you can judge”

You can now follow a Function from record to runtime and back, say how each caller invokes it and reads its answer, list the bounds of every outbound call, and judge an integration by whose identity it carries and how it fails. Next, M6-S2: the package contract, the surface that carries a whole design, Functions included, from one environment to another.