Skip to content

feat(function): Add support for micro-sandbox configuration#159

Open
liuzewen99 wants to merge 1 commit into
masterfrom
fix-microSandboxConfig
Open

feat(function): Add support for micro-sandbox configuration#159
liuzewen99 wants to merge 1 commit into
masterfrom
fix-microSandboxConfig

Conversation

@liuzewen99

@liuzewen99 liuzewen99 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added function-level micro-sandbox configuration (OS type, readiness command, startup command) and exposed it through the configuration schema.
  • Bug Fixes
    • Improved micro-sandbox local runtime routing so invoke/start paths are exercised correctly.
  • Tests
    • Added/updated unit tests to ensure micro-sandbox settings are forwarded when provided and omitted when not.
  • Chores
    • Bumped the FC platform dependency to a newer patch version.

@liuzewen99 liuzewen99 requested a review from rsonghuster July 2, 2026 06:34
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 158f3602-c4e4-4e39-ab47-c4b9481b78a1

📥 Commits

Reviewing files that changed from the base of the PR and between a8aa7b7 and 8ed590f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • __tests__/complete-props.yaml
  • __tests__/ut/local/local_test.ts
  • __tests__/ut/resources/fc/impl/client_test.ts
  • package.json
  • src/interface/function.ts
  • src/schema.json
✅ Files skipped from review due to trivial changes (1)
  • tests/complete-props.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/ut/local/local_test.ts
  • src/schema.json
  • src/interface/function.ts
  • tests/ut/resources/fc/impl/client_test.ts
  • package.json

📝 Walkthrough

Walkthrough

This PR adds microSandboxConfig to the function type and schema, updates local runtime routing tests for micro-sandbox, extends client request payload tests, and bumps the @alicloud/fc20230330 dependency.

Changes

microSandboxConfig feature

Layer / File(s) Summary
Interface and schema definitions
src/interface/function.ts, src/schema.json
Adds IMicroSandboxConfig and the matching microSandboxConfig property on IFunction, plus the corresponding schema definition and top-level schema reference.
Local runtime routing tests
__tests__/ut/local/local_test.ts
Adds invoke and start coverage for routing the micro-sandbox runtime through the custom container local implementations.
Client payload and fixture updates
__tests__/complete-props.yaml, package.json, __tests__/ut/resources/fc/impl/client_test.ts
Adds a microSandboxConfig fixture block, bumps @alicloud/fc20230330, and extends create/update client tests to assert microSandboxConfig is forwarded in request payloads when present.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • devsapp/fc3#156: Both PRs modify micro-sandbox-related schema/runtime handling, and this PR also forwards microSandboxConfig into request payloads.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding micro-sandbox configuration support to functions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-microSandboxConfig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
__tests__/ut/resources/fc/impl/client_test.ts (1)

271-313: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a negative-path test for updateFunction, mirroring createFunction.

createFunction tests cover both "with microSandboxConfig" and "without microSandboxConfig" cases, but updateFunction only tests the positive path. Add a symmetric test asserting bodyMap.microSandboxConfig is undefined when omitted, for consistent coverage of the request-forwarding contract.

♻️ Suggested addition
     it('should forward microSandboxConfig to the update request body', async () => {
       ...
     });
+
+    it('should not set microSandboxConfig on update when it is not provided', async () => {
+      const updateFunctionWithOptions = jest.fn().mockResolvedValue({} as any);
+      Object.defineProperty(client, 'fc20230330Client', {
+        value: { updateFunctionWithOptions },
+        writable: true,
+      });
+
+      await client.updateFunction({
+        functionName: 'test-function',
+        runtime: 'nodejs18',
+      } as IFunction);
+
+      const bodyMap = updateFunctionWithOptions.mock.calls[0][1].body.toMap();
+      expect(bodyMap.microSandboxConfig).toBeUndefined();
+    });
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@__tests__/ut/resources/fc/impl/client_test.ts` around lines 271 - 313, Add a
negative-path test for updateFunction to match the createFunction coverage: the
current test only verifies microSandboxConfig is forwarded when present, but
there is no assertion for the omitted case. Add a sibling test in the
updateFunction describe block that calls FC_Client.updateFunction without
microSandboxConfig, inspects the mocked updateFunctionWithOptions request body,
and asserts bodyMap.microSandboxConfig is undefined to keep the
request-forwarding contract consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@__tests__/ut/resources/fc/impl/client_test.ts`:
- Around line 271-313: Add a negative-path test for updateFunction to match the
createFunction coverage: the current test only verifies microSandboxConfig is
forwarded when present, but there is no assertion for the omitted case. Add a
sibling test in the updateFunction describe block that calls
FC_Client.updateFunction without microSandboxConfig, inspects the mocked
updateFunctionWithOptions request body, and asserts bodyMap.microSandboxConfig
is undefined to keep the request-forwarding contract consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de752600-a5df-45e3-8e60-51121bff0e67

📥 Commits

Reviewing files that changed from the base of the PR and between 1223905 and a8aa7b7.

📒 Files selected for processing (2)
  • __tests__/ut/local/local_test.ts
  • __tests__/ut/resources/fc/impl/client_test.ts

@liuzewen99 liuzewen99 force-pushed the fix-microSandboxConfig branch from 15897f2 to 8ed590f Compare July 3, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant