Skip to content

feat: add additional function config properties#7064

Merged
eduardoboucas merged 15 commits into
mainfrom
feat/function-region
May 19, 2026
Merged

feat: add additional function config properties#7064
eduardoboucas merged 15 commits into
mainfrom
feat/function-region

Conversation

@eduardoboucas
Copy link
Copy Markdown
Member

@eduardoboucas eduardoboucas commented May 18, 2026

Adds region, memory and vcpu.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds support for optional function region and memory configuration: registers region as a recognized key, adds post-normalize validations for both fields, introduces runtime Zod schemas that normalize/validate region and memory, adds a parseMemoryMB helper to normalize memory inputs to MB with tests, propagates optional region and memory through static analysis/formatting into the build manifest, and updates fixtures and unit/integration tests to cover extraction, normalization, validation, and precedence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is completely empty, missing all required template sections including summary, motivation, and completion checklist. Add a comprehensive description explaining the motivation, what problem this solves, and confirm completion of the pre-submission checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The PR title 'feat: add additional function config properties' directly summarizes the main change—adding region and memory configuration properties across multiple files in the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/function-region

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

@github-actions
Copy link
Copy Markdown
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@eduardoboucas eduardoboucas marked this pull request as ready for review May 18, 2026 16:52
@eduardoboucas eduardoboucas requested a review from a team as a code owner May 18, 2026 16:52
@eduardoboucas eduardoboucas changed the title feat: add region config property feat: add region and memory config properties May 18, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts (1)

6-20: ⚡ Quick win

Add a decimal-number test for the number-input branch.

The number path currently lacks a decimal case, so it won’t catch divergence from the “integer MB normalization” behavior.

Suggested test addition
   describe('number inputs', () => {
@@
     test('passes through negative numbers (range checks are the caller’s concern)', () => {
       expect(parseMemoryMB(-128)).toBe(-128)
     })
+
+    test('normalizes decimal numbers to integer MB', () => {
+      expect(parseMemoryMB(1024.5)).toBe(1025)
+    })
   })
🤖 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 `@packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts` around
lines 6 - 20, Add a test case in the number-input suite of parse_memory.test.ts
to assert parseMemoryMB preserves decimal numbers (e.g., 512.5) so the number
branch is covered for non-integers; locate the describe('number inputs') block
and add a new test that calls parseMemoryMB with a decimal value and expects the
same decimal value to be returned, referencing parseMemoryMB to validate
integer-normalization behavior doesn't inadvertently coerce or round decimals.
packages/zip-it-and-ship-it/src/utils/format_result.ts (1)

28-29: ⚡ Quick win

Remove unnecessary type assertion on memory propagation.

Line 28's as number | undefined is redundant—both archive.staticAnalysisResult?.config?.memory and archive.config?.memory already infer to number | undefined from the underlying Zod schemas, so the nullish coalesce result is correctly typed without it. Removing the assertion keeps type drift detectable by TypeScript. Extracting both values to local variables (as suggested) improves consistency and readability.

Suggested change
 export const formatZipResult = (archive: FunctionArchive) => {
+  const memory = archive.staticAnalysisResult?.config?.memory ?? archive.config?.memory
+  const region = archive.staticAnalysisResult?.config?.region ?? archive.config?.region
+
   const functionResult: FunctionResult = {
     ...archive,
     staticAnalysisResult: undefined,
     eventSubscriptions: archive.staticAnalysisResult?.eventSubscriptions,
     routes: archive.staticAnalysisResult?.routes,
     excludedRoutes: archive.staticAnalysisResult?.excludedRoutes,
     runtime: archive.runtime.name,
-    memory: (archive.staticAnalysisResult?.config?.memory ?? archive?.config?.memory) as number | undefined,
-    region: archive.staticAnalysisResult?.config?.region ?? archive?.config?.region,
+    memory,
+    region,
     schedule: archive.staticAnalysisResult?.config?.schedule ?? archive?.config?.schedule,
     runtimeAPIVersion: archive.staticAnalysisResult?.runtimeAPIVersion,
   }
🤖 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 `@packages/zip-it-and-ship-it/src/utils/format_result.ts` around lines 28 - 29,
Remove the unnecessary type assertion on the memory propagation line: drop "as
number | undefined" from the expression that assigns memory (the
nullish-coalesced result of archive.staticAnalysisResult?.config?.memory ??
archive?.config?.memory) so TypeScript can correctly infer its type; optionally
extract archive.staticAnalysisResult?.config?.memory and archive?.config?.memory
into local variables first to improve readability and consistency with the
region propagation logic.
🤖 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.

Inline comments:
In `@packages/zip-it-and-ship-it/src/utils/parse_memory.ts`:
- Around line 1-23: The file fails the oxfmt formatting check; run the
repository formatter (run `oxfmt --apply` or your project's standard format
command) on packages/zip-it-and-ship-it/src/utils/parse_memory.ts to fix
whitespace/formatting around the constants and the parseMemoryMB function
(symbols: MEMORY_UNIT_TO_MB, MEMORY_PATTERN, parseMemoryMB), then re-commit the
formatted file so CI's `oxfmt --check` passes.
- Around line 10-11: In parseMemory, the numeric branch currently returns the
raw input which allows decimals to bypass normalization; update the numeric path
(the check using "if (typeof input === 'number')" / the input parameter) to
apply the same integer rounding used for string inputs (e.g., Math.round or the
existing rounding logic used on the string branch) so numbers are normalized to
integer MB before returning.

---

Nitpick comments:
In `@packages/zip-it-and-ship-it/src/utils/format_result.ts`:
- Around line 28-29: Remove the unnecessary type assertion on the memory
propagation line: drop "as number | undefined" from the expression that assigns
memory (the nullish-coalesced result of
archive.staticAnalysisResult?.config?.memory ?? archive?.config?.memory) so
TypeScript can correctly infer its type; optionally extract
archive.staticAnalysisResult?.config?.memory and archive?.config?.memory into
local variables first to improve readability and consistency with the region
propagation logic.

In `@packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts`:
- Around line 6-20: Add a test case in the number-input suite of
parse_memory.test.ts to assert parseMemoryMB preserves decimal numbers (e.g.,
512.5) so the number branch is covered for non-integers; locate the
describe('number inputs') block and add a new test that calls parseMemoryMB with
a decimal value and expects the same decimal value to be returned, referencing
parseMemoryMB to validate integer-normalization behavior doesn't inadvertently
coerce or round decimals.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d32dc83-bdcb-41f6-8cf2-661330163c84

📥 Commits

Reviewing files that changed from the base of the PR and between 1b85f24 and 91bd87f.

📒 Files selected for processing (9)
  • packages/zip-it-and-ship-it/src/config.ts
  • packages/zip-it-and-ship-it/src/manifest.ts
  • packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/index.ts
  • packages/zip-it-and-ship-it/src/utils/format_result.ts
  • packages/zip-it-and-ship-it/src/utils/parse_memory.ts
  • packages/zip-it-and-ship-it/tests/fixtures-esm/v2-api-name-generator/.netlify/functions-internal/server.mjs
  • packages/zip-it-and-ship-it/tests/unit/runtimes/node/in_source_config.test.ts
  • packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts
  • packages/zip-it-and-ship-it/tests/v2api.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/index.ts
  • packages/zip-it-and-ship-it/tests/v2api.test.ts
  • packages/zip-it-and-ship-it/tests/unit/runtimes/node/in_source_config.test.ts

Comment thread packages/zip-it-and-ship-it/src/utils/parse_memory.ts Outdated
Comment thread packages/zip-it-and-ship-it/src/utils/parse_memory.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@packages/zip-it-and-ship-it/src/utils/parse_memory.ts`:
- Around line 9-12: The number branch in parseMemoryMB currently rounds numeric
input but doesn't guard against Infinity/-Infinity or negative numbers; update
the typeof input === 'number' branch in parseMemoryMB to first check
Number.isFinite(input) and that input is >= 0, then return Math.round(input),
otherwise return NaN so Infinity, -Infinity and negative numeric memory values
are treated as invalid consistent with string parsing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0e959d8-2f2c-4595-b611-680724609cbf

📥 Commits

Reviewing files that changed from the base of the PR and between 91bd87f and 4ca147e.

📒 Files selected for processing (4)
  • packages/config/src/functions_config.js
  • packages/config/src/validate/validations.js
  • packages/zip-it-and-ship-it/src/utils/parse_memory.ts
  • packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/config/src/functions_config.js
  • packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts

Comment thread packages/zip-it-and-ship-it/src/utils/parse_memory.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@packages/zip-it-and-ship-it/src/utils/parse_memory.ts`:
- Around line 22-25: The string parsing path in parse_memory.ts can produce
Infinity for extremely large inputs because Math.round(value *
MEMORY_UNIT_TO_MB[unit]) isn’t checked; mirror the numeric path’s guard by
computing the converted value into a variable (e.g., const bytes =
Math.round(value * MEMORY_UNIT_TO_MB[unit])) and then verify
Number.isFinite(bytes) (or Number.isFinite(value) before rounding) and return
NaN (or handle the same rejection as the numeric branch) if it's not finite;
reference the symbols value, unit, MEMORY_UNIT_TO_MB and the Math.round call
when making this change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16cbafee-75d1-4269-ba4d-195325849bf7

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca147e and 60e90da.

📒 Files selected for processing (3)
  • packages/zip-it-and-ship-it/src/utils/format_result.ts
  • packages/zip-it-and-ship-it/src/utils/parse_memory.ts
  • packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/zip-it-and-ship-it/tests/unit/utils/parse_memory.test.ts
  • packages/zip-it-and-ship-it/src/utils/format_result.ts

Comment on lines +22 to +25
const value = parseFloat(match[1])
const unit = match[2] || 'mb'

return Math.round(value * MEMORY_UNIT_TO_MB[unit])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard against overflow to Infinity in string path.

After unit conversion, extremely large inputs (e.g., "999999999999999gb") can overflow to Infinity. Unlike the numeric path, which explicitly rejects infinite values, Math.round(Infinity) returns Infinity rather than NaN.

This is an edge case unlikely to occur with valid memory values, but it's inconsistent with the finite guard in the numeric branch.

🛡️ Proposed fix to ensure consistency
  const value = parseFloat(match[1])
  const unit = match[2] || 'mb'
+ const result = value * MEMORY_UNIT_TO_MB[unit]
+ return Number.isFinite(result) ? Math.round(result) : Number.NaN
- return Math.round(value * MEMORY_UNIT_TO_MB[unit])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const value = parseFloat(match[1])
const unit = match[2] || 'mb'
return Math.round(value * MEMORY_UNIT_TO_MB[unit])
const value = parseFloat(match[1])
const unit = match[2] || 'mb'
const result = value * MEMORY_UNIT_TO_MB[unit]
return Number.isFinite(result) ? Math.round(result) : Number.NaN
🤖 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 `@packages/zip-it-and-ship-it/src/utils/parse_memory.ts` around lines 22 - 25,
The string parsing path in parse_memory.ts can produce Infinity for extremely
large inputs because Math.round(value * MEMORY_UNIT_TO_MB[unit]) isn’t checked;
mirror the numeric path’s guard by computing the converted value into a variable
(e.g., const bytes = Math.round(value * MEMORY_UNIT_TO_MB[unit])) and then
verify Number.isFinite(bytes) (or Number.isFinite(value) before rounding) and
return NaN (or handle the same rejection as the numeric branch) if it's not
finite; reference the symbols value, unit, MEMORY_UNIT_TO_MB and the Math.round
call when making this change.

@eduardoboucas eduardoboucas changed the title feat: add region and memory config properties feat: add additional function config properties May 19, 2026
@eduardoboucas eduardoboucas merged commit 41bf8da into main May 19, 2026
56 of 57 checks passed
@eduardoboucas eduardoboucas deleted the feat/function-region branch May 19, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants