Skip to content
Merged
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
38 changes: 38 additions & 0 deletions go/models/deploy.go

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

46 changes: 46 additions & 0 deletions go/models/deploy_functions_region_overrides_items.go

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

3 changes: 3 additions & 0 deletions go/models/function.go

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

3 changes: 3 additions & 0 deletions go/models/function_config.go

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

3 changes: 2 additions & 1 deletion go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,12 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
}
}

hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0 || len(function.EventSubscriptions) > 0
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0 || len(function.EventSubscriptions) > 0 || function.Region != ""
if hasConfig {
cfg := models.FunctionConfig{
DisplayName: function.DisplayName,
Generator: function.Generator,
Region: function.Region,
Routes: routes,
ExcludedRoutes: excludedRoutes,
BuildData: function.BuildData,
Expand Down
1 change: 1 addition & 0 deletions go/porcelain/functions_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type functionsManifestEntry struct {
MainFile string `json:"mainFile"`
Name string `json:"name"`
Path string `json:"path"`
Region string `json:"region"`
Runtime string `json:"runtime"`
RuntimeVersion string `json:"runtimeVersion"`
Schedule string `json:"schedule"`
Expand Down
20 changes: 20 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4586,6 +4586,8 @@ definitions:
type: string
sha:
type: string
region:
type: string
Comment on lines +4589 to +4590

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

Tighten schema validation for region fields and overrides.

region is documented as an airport code, but these fields currently accept any string, and override items allow missing name/region. This weak contract lets malformed payloads pass client-side validation.

🔧 Suggested schema constraints
   function:
     type: object
     properties:
@@
       region:
         type: string
+        pattern: '^[a-z]{3}$'
+        minLength: 3
+        maxLength: 3

@@
       functions_region:
         type: string
         description: |
           The functions region for this deploy as an airport code.
+        pattern: '^[a-z]{3}$'
+        minLength: 3
+        maxLength: 3
       functions_region_overrides:
         type: array
         items:
           type: object
+          required:
+            - name
+            - region
           properties:
             name:
               type: string
+              minLength: 1
             region:
               type: string
+              pattern: '^[a-z]{3}$'
+              minLength: 3
+              maxLength: 3

@@
   functionConfig:
     type: object
     properties:
@@
       region:
         type: string
+        pattern: '^[a-z]{3}$'
+        minLength: 3
+        maxLength: 3

Also applies to: 4694-4709, 5568-5569

🤖 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 `@swagger.yml` around lines 4589 - 4590, The schemas currently declare region
as just "type: string" and allow override items to omit name/region; tighten
these by changing the region property to a constrained string (e.g., add
pattern: "^[A-Z]{3}$" and minLength/maxLength as appropriate for your airport
code format, or an enum if you have a finite list) and update the override item
schemas to mark "name" and "region" as required; locate and update the
occurrences of the region property and the override item object definitions (the
"region" field and the override items referenced around the other occurrences)
to include the pattern/length constraints and add required: ["name","region"] so
malformed payloads are rejected by validation.

snippet:
type: object
properties:
Expand Down Expand Up @@ -4689,6 +4691,22 @@ definitions:
type: array
items:
$ref: '#/definitions/functionSchedule'
functions_region:
type: string
description: |
The functions region for this deploy as an airport code.
functions_region_overrides:
type: array
items:
type: object
properties:
name:
type: string
region:
type: string
description: |
Functions in the deploy that explicitly specify their own region
(airport code).
deployEnvironmentVariable:
type: object
required:
Expand Down Expand Up @@ -5547,6 +5565,8 @@ definitions:
$ref: '#/definitions/excludedFunctionRoute'
priority:
type: integer
region:
type: string
traffic_rules:
$ref: '#/definitions/trafficRulesConfig'
event_subscriptions:
Expand Down
Loading