Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions __tests__/ut/resources/fc/impl/utils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ describe('utils', () => {
expect(result).toBe(true);
});

it('should return true for micro-sandbox runtime', () => {
const result = isCustomContainerRuntime('micro-sandbox');
expect(result).toBe(true);
});

it('should return false for non custom-container runtime', () => {
const result = isCustomContainerRuntime('nodejs18');
expect(result).toBe(false);
Expand Down
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@alicloud/devs20230714": "^2.5.0",
"@alicloud/fc2": "^2.6.6",
"@alicloud/fc20230330": "4.7.4",
"@alicloud/fc20230330": "4.7.5",
"@alicloud/pop-core": "^1.8.0",
"@serverless-cd/srm-aliyun-oss": "^0.0.1-beta.8",
"@serverless-cd/srm-aliyun-pop-core": "^0.0.8-beta.1",
Expand Down
2 changes: 1 addition & 1 deletion publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Component
Name: fc3
Provider:
- 阿里云
Version: 0.1.21
Version: 0.1.22
Description: 阿里云函数计算全生命周期管理
HomePage: https://github.com/devsapp/fc3
Organization: 阿里云函数计算(FC)
Expand Down
1 change: 1 addition & 0 deletions src/interface/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export enum Runtime {
'custom.debian12' = 'custom.debian12',
'custom' = 'custom',
'custom-container' = 'custom-container',
'micro-sandbox' = 'micro-sandbox',
}

export const RuntimeList = Object.values(Runtime);
Expand Down
2 changes: 1 addition & 1 deletion src/resources/fc/impl/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { isDebugMode } from '@serverless-devs/utils';

export function isCustomContainerRuntime(runtime: string): boolean {
return runtime === Runtime['custom-container'];
return runtime === Runtime['custom-container'] || runtime === Runtime['micro-sandbox'];
}

export function isCustomRuntime(runtime: string): boolean {
Expand Down Expand Up @@ -45,7 +45,7 @@
if (stat.isDirectory()) {
continue;
}
const newMode = stat.mode | 0o111;

Check warning on line 48 in src/resources/fc/impl/utils.ts

View workflow job for this annotation

GitHub Actions / check-format

Unexpected use of '|'
fs.chmodSync(filePath, newMode);
logger.info(`Set executable permission for: ${filePath}`);
} catch (fileError) {
Expand Down
3 changes: 2 additions & 1 deletion src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@
"enum": [
"custom",
"custom-container",
"micro-sandbox",
"custom.debian10",
"custom.debian11",
"custom.debian12",
Expand Down Expand Up @@ -1428,7 +1429,7 @@
"properties": {
"runtime": {
"type": "string",
"const": "custom-container"
"enum": ["custom-container", "micro-sandbox"]
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/subCommands/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export default class ComponentLocal {
await customLocalInvoker.invoke();
break;
}
case 'custom-container': {
case 'custom-container':
case 'micro-sandbox': {
const customContainerLocalInvoker = new CustomContainerLocalInvoke(inputs);
await customContainerLocalInvoker.invoke();
break;
Comment on lines +86 to 90
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix micro-sandbox/custom-container guard mismatch before routing.

At Line 87 and Line 161, micro-sandbox is routed to custom-container handlers, but downstream src/subCommands/local/impl/baseLocal.ts still treats only 'custom-container' as custom-container runtime. This will trip guard checks (and can throw) in custom-container invoke/start flows.

Suggested fix (root cause)
diff --git a/src/subCommands/local/impl/baseLocal.ts b/src/subCommands/local/impl/baseLocal.ts
@@
   isCustomContainerRuntime(): boolean {
-    return this.inputs.props.runtime === 'custom-container';
+    return (
+      this.inputs.props.runtime === 'custom-container' ||
+      this.inputs.props.runtime === 'micro-sandbox'
+    );
   }

Also applies to: 160-164

🤖 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 `@src/subCommands/local/index.ts` around lines 86 - 90, The routing sends
'micro-sandbox' to the CustomContainer flows but the guard in baseLocal.ts only
recognizes 'custom-container', causing guard failures; update the runtime check
used in the custom container guard inside
src/subCommands/local/impl/baseLocal.ts (the method that validates runtime
before invoke/start) to accept both 'custom-container' and 'micro-sandbox'
(e.g., check runtime === 'custom-container' || runtime === 'micro-sandbox') or
centralize the mapping so the guard and the switch routing (where
CustomContainerLocalInvoke is constructed) use the same canonical runtime values
(CustomContainerLocalInvoke, the guard method in baseLocal.ts).

Expand Down Expand Up @@ -156,7 +157,8 @@ export default class ComponentLocal {
await customLocalStart.start();
break;
}
case 'custom-container': {
case 'custom-container':
case 'micro-sandbox': {
const customContainerLocalStart = new CustomContainerLocalStart(inputs);
await customContainerLocalStart.start();
break;
Expand Down
Loading