You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config/source/skills/cloud-functions/SKILL.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,8 @@ Keep local `references/...` paths for files that ship with the current skill dir
54
54
- Forgetting that runtime cannot be changed after creation.
55
55
- Using cloud functions as the first answer for Web login.
56
56
- Forgetting that HTTP Functions must ship `scf_bootstrap`, listen on port `9000`, and include dependencies.
57
+
- Forgetting to configure function security rules after creating an HTTP Function. Default rules reject anonymous callers with `EXCEED_AUTHORITY`. Use `managePermissions(action="updateResourcePermission", resourceType="function")` to allow public access.
58
+
- Mismatching the `scf_bootstrap` Node.js binary path with the function runtime (e.g. using `/var/lang/node18/bin/node` but setting `runtime: "Nodejs16.13"`).
- HTTP Function: `req` / `res`, listens on port `9000`
10
10
2. Pick the runtime before creation and state it explicitly.
11
-
3. For HTTP Functions, confirm `scf_bootstrap` exists and the service listens on port `9000`.
11
+
3. For HTTP Functions, confirm `scf_bootstrap` exists and the Node.js binary path matches the runtime (e.g. `Nodejs18.15` → `/var/lang/node18/bin/node`).
12
12
4. Confirm the function root path points to the parent directory, not the function directory itself.
13
-
5. If the request is really for a long-running container service, reroute to `cloudrun-development`.
13
+
5. For HTTP Functions that need anonymous access, configure the function security rule with `managePermissions(action="updateResourcePermission", resourceType="function")` after creation. Default rules reject anonymous callers with `EXCEED_AUTHORITY`.
14
+
6. If the request is really for a long-running container service, reroute to `cloudrun-development`.
14
15
15
16
## Common failure patterns
16
17
17
18
- Choosing the wrong function type and compensating later.
18
19
- Mixing Event Function and HTTP Function handler shapes in the same implementation.
19
20
- Forgetting that runtime cannot be changed after creation.
21
+
- Mismatching the `scf_bootstrap` Node.js binary path with the function runtime.
22
+
- Forgetting to configure function security rules for HTTP Functions that need anonymous access.
20
23
- Treating Cloud Functions as the default answer for Web authentication.
Express 5 note: `app.all("/{*splat}", (req, res) => {` is the safe catch-all form when you also need to match the root path `/`, because the router is based on `path-to-regexp` rather than the older Express 4 wildcard behavior.
205
215
216
+
## End-to-end deployment lifecycle
217
+
218
+
Follow these steps in order when creating an HTTP Function:
219
+
220
+
1.**Write the function code** — create the directory with `index.js`, `scf_bootstrap`, and `package.json`.
221
+
2.**Deploy with `manageFunctions`** — set `type: "HTTP"`, `protocolType: "HTTP"`, and `runtime` explicitly.
222
+
3.**Configure security rules** — HTTP Functions default to a restrictive security rule. If the function should be publicly accessible (anonymous access), call `managePermissions(action="updateResourcePermission")` with `resourceType="function"`.
223
+
4.**Verify** — call the function URL and confirm it returns the expected response. If you get `EXCEED_AUTHORITY`, the security rule needs to be updated (step 3).
-`type: "HTTP"` — marks the function as an HTTP Function (not an Event Function).
246
+
-`protocolType: "HTTP"` — the wire protocol. Use `"WS"` for WebSocket.
247
+
-`runtime` — the execution runtime. Must match the `scf_bootstrap` binary path. Default is `"Nodejs18.15"` if omitted, but always set it explicitly to avoid ambiguity.
248
+
-`functionRootPath` — the parent directory of the function folder (e.g. `/path/to/cloudfunctions` if the code lives in `/path/to/cloudfunctions/myHttpFunction/`).
249
+
250
+
### Security rule configuration
251
+
252
+
After creating an HTTP Function, it will reject anonymous callers with `EXCEED_AUTHORITY` by default. If the function should be publicly accessible:
253
+
254
+
```javascript
255
+
managePermissions({
256
+
action:"updateResourcePermission",
257
+
resourceType:"function",
258
+
resourceId:"myHttpFunction",
259
+
permission: {
260
+
aclTag:"CUSTOM",
261
+
rule:"true"
262
+
}
263
+
});
264
+
```
265
+
266
+
-`aclTag: "CUSTOM"` with `rule: "true"` allows all callers (anonymous access).
267
+
- Do NOT use `readSecurityRule` / `writeSecurityRule` — those are removed. Use `queryPermissions` / `managePermissions` instead.
268
+
- Security rule semantics for `resourceType="function"` differ from NoSQL database rules. Do not reuse `doc._openid` or `auth.openid` expressions from NoSQL security rules.
269
+
- Official reference: `https://docs.cloudbase.net/cloud-function/security-rules`
270
+
271
+
If an external caller reports `EXCEED_AUTHORITY`, inspect the function permission first with `queryPermissions(action="getResourcePermission", resourceType="function", resourceId="myHttpFunction")` before widening access.
272
+
223
273
### WebSocket
224
274
225
275
For WebSocket workloads, keep the function type as HTTP and switch `protocolType`:
@@ -264,9 +314,7 @@ manageGateway({
264
314
Before enabling anonymous access, confirm both of these:
265
315
266
316
1. The access path exists.
267
-
2. The function security rule allows the intended caller identity.
268
-
269
-
If an external caller reports `EXCEED_AUTHORITY`, inspect the function permission first with `queryPermissions(action="getResourcePermission", resourceType="function")` before widening access.
317
+
2. The function security rule allows the intended caller identity (see Security rule configuration above).
0 commit comments