Skip to content

Make function name optional in function.json schema#378

Open
kfirstri wants to merge 2 commits intomainfrom
claude/issue-373-20260308-0922
Open

Make function name optional in function.json schema#378
kfirstri wants to merge 2 commits intomainfrom
claude/issue-373-20260308-0922

Conversation

@kfirstri
Copy link
Collaborator

@kfirstri kfirstri commented Mar 8, 2026

Note

Description

This PR makes the name field optional in function.json/function.jsonc config files. When omitted, the function name is automatically derived from the directory path relative to the functions root, matching the existing behavior for zero-config (config-less) functions. This provides a more ergonomic authoring experience where users don't need to repeat the directory name in a config field.

Related Issue

Closes #373

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Made name field optional in FunctionConfigSchema (Zod schema) so function.jsonc files can omit it
  • Added name as a required field on BackendFunctionSchema (the resolved internal type) to enforce it is always present after processing
  • Updated readFunction() to accept a functionsDir parameter and derive the name from the relative path when name is absent in the config
  • Path-based name derivation normalizes separators cross-platform via relative(functionsDir, functionDir).split(/[/\\]/).join("/")
  • Added a test fixture (no-name-in-config/) with a function.jsonc that omits the name field
  • Added/updated tests to cover the path-based fallback naming behavior (expected count bumped from 4 to 5)

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The path-based fallback is consistent with how zero-config (config-less) functions already derive their names from the directory structure, so this change makes the two approaches behaviorally equivalent when name is omitted.


🤖 Generated by Claude | 2026-03-08 09:30 UTC

…h-based name

When `name` is omitted from a function.json/function.jsonc config file, the
function name is now derived from the directory path relative to the functions
root — matching the existing behavior for zero-config (config-less) functions.

Closes #373

Co-authored-by: Kfir Stri <kfirstri@users.noreply.github.com>
@kfirstri kfirstri self-assigned this Mar 8, 2026
@kfirstri kfirstri added the bug Something isn't working label Mar 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.38-pr.378.bb7fa12

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.38-pr.378.bb7fa12"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.38-pr.378.bb7fa12"
  }
}

Preview published to npm registry — try new features instantly!

@kfirstri kfirstri moved this from Backlog to In progress in CLI Development Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Function name should be default path name

1 participant