M6-S1 — Integration surfaces inside: Functions, webhooks and connectors
Section titled “M6-S1 — Integration surfaces inside: Functions, webhooks and connectors”| Module | M6 — Extension design |
| After this session you can | Explain how a Function is provisioned and invoked, how an outbound call and a connector behave under failure, and judge an integration from that. |
| Time | 65 min with a facilitator · about 65 min on your own |
| Before you start | M4-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 deeper | Functions: 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”From record to running service
Section titled “From record to running service”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.yamlandparams.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.
Three ways a Function is called
Section titled “Three ways a Function is called”| Caller | Path | What it sends | How the answer is read |
|---|---|---|---|
| A reaction’s Execute Function action | The reaction service posts straight to the Function URL | A CloudEvent whose data is {context, parameters}: the run’s context and the parameters the builder mapped | Any answer counts as the action having run; your success flag travels in the output for chained reactions |
| A validator, before a save | The 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 program | POST /api/functions/v1/<function id>/execute, with a credential since 1.10 | Your JSON body | The 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.
An outbound call, bounded
Section titled “An outbound call, bounded”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:
| Bound | Rule |
|---|---|
| Destination | http 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 |
| Time | One deadline for the whole exchange, 30 seconds by default |
| Size | Request and response bodies, and what is recorded, at most 10 MiB |
| Headers | The 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 values | A call whose address, headers or body would carry a masked sensitive value fails instead of sending the mask |
| Success | A 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.
- Open Administration › Applications › Functions and open spare-part-price. Read its Status, its Function URL and its parameters.
- 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.
- 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. - Change the function’s description and save. Status stays Provisioned and the URL is unchanged: no rebuild.
- 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.
✓ Practice (4 min) — The lifecycle
Section titled “✓ Practice (4 min) — The lifecycle”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?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
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?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
A value validator answers Invalid serial number as plain text when a serial is wrong. What does the
person saving the record see?
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.
-
Create the project
echo-contextwithfunc.yaml,params.yaml,package.jsonandtsconfig.jsonexactly as in ACE M4-S1, with the nameecho-contextand these parameters inparams.yaml:version: "1"parameters:- name: part- name: quantity -
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 }; -
Build and test locally (
npm install,npm run build,npm start, then onecurlwith{"parameters":{"part":"x","quantity":1}}), stop it, and zip it withoutnode_modulesandbuild. -
In Functions, select Add Function: name echo-context, Reaction Custom Action, scope module Asset Maintenance, the ZIP. Save.
-
Reload until Provisioned. Note the time it took and the Function URL’s deployed name.
-
On Spare Parts, add the reaction Echo on update: On Entry Updated, Execute Function echo-context,
partmapped to Name,quantitymapped to Stock. Save. -
Edit the spare part Mechanical seal 40 mm and change Stock to 12.
-
In Reaction Logs, open the run. In the output’s
result:receivedlistscontextandparameters;parametersshows the name and 12;tenantSetandapiBaseSetare true. -
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.
-
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}}' | jqThe answer is the function’s JSON:
receivedlists onlyparameters, because you sent no context. ThisPOSTis the one exception to the workbench’s GET-only rule: echo-context reads and writes nothing. -
Call it again without the token. The gateway refuses it.
-
Change
message: 'echo'tomessage: '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. -
Trigger step 7 again. The output shows
echo v2. -
Archive echo-context. Call step 10 again: refused with a not-found or not-active error.
-
Open the reaction Echo on update: its function is no longer available. Delete the reaction.
-
Note in your table, for each stage, where you saw it: record, run history, API.
-
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
contextandparameters, 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 see | What to do |
|---|---|
| Provisioning for more than ten minutes | Ask your training provider whether the function builder is running for your space; your local test in step 3 still stands. |
| Build failed | Read Provisioning Error; usually func.yaml is not at the ZIP’s root. |
received is empty in step 8 | You 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 403 | TOKEN 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”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?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
A CMMS team asks how to verify that a webhook really came from Larkspur’s platform. What do you tell them?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
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?
Check your answer
The correct answer is A. Open the explanation under each option to see why.
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?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
A Grafana data source was set up with Forward OAuth Identity off. What do viewers notice?
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.