Skip to content

Add backend function versioning support#29

Merged
GabiGrin merged 3 commits intomainfrom
feat/backend-function-versioning
Sep 10, 2025
Merged

Add backend function versioning support#29
GabiGrin merged 3 commits intomainfrom
feat/backend-function-versioning

Conversation

@GabiGrin
Copy link
Collaborator

@GabiGrin GabiGrin commented Sep 9, 2025

Summary

Changes

  • Modified functions module to include Base44-Functions-Version header in all function calls
  • Added functionsVersion parameter support in client configuration
  • Updated createClientFromRequest to extract and pass functions version from headers

- Add extractSnapshotIdFromHost utility to detect environment from URL
- Include Base44-Functions-Version header in function calls
- Support functionsVersion parameter in client configuration
- Automatically route function calls to correct deployment based on URL pattern

This ensures backend functions work correctly with app versioning,
calling the right deployment for production, preview, and checkpoint environments.
@github-actions
Copy link

github-actions bot commented Sep 9, 2025

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.7.0-pr.29.7a5b54e

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

npm i "@base44/sdk@npm:@base44-preview/sdk@0.7.0-pr.29.7a5b54e"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.7.0-pr.29.7a5b54e"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Sep 9, 2025

Claude finished @GabiGrin's task —— View job


Pull Request Review: Add backend function versioning support

I've completed my review of this PR. Here's my comprehensive feedback:

Review Summary

This PR adds backend function versioning support by introducing a functionsVersion parameter to the client configuration. The implementation is clean and follows the existing patterns in the codebase.


🟢 Strengths

  1. Clean Implementation: The changes are minimal and focused, following the existing code patterns in the SDK.

  2. Backward Compatibility: The functionsVersion parameter is optional, ensuring existing clients continue to work without modification.

  3. Consistent Header Handling: The PR correctly implements separate headers for function-related axios clients while maintaining the base headers for other modules.

  4. Proper Header Extraction: The createClientFromRequest function correctly extracts the Base44-Functions-Version header and passes it through.


🟡 Areas for Improvement

1. Missing Test Coverage

The test suite doesn't include any tests for the new versioning functionality:

  • No tests verify that the Base44-Functions-Version header is included when functionsVersion is provided
  • No tests for createClientFromRequest extracting and passing the version header
  • No tests for both regular and service role function clients receiving the header

Recommendation: Add tests similar to this pattern:

test("should include Base44-Functions-Version header when functionsVersion is provided", async () => {
  const functionsVersion = "v2-snapshot-123";
  const versionedClient = createClient({
    serverUrl,
    appId,
    functionsVersion,
  });
  
  // Mock and verify the header is sent
  scope
    .post(`/api/apps/${appId}/functions/testFunction`)
    .matchHeader("Base44-Functions-Version", functionsVersion)
    .reply(200, { success: true });
    
  await versionedClient.functions.invoke("testFunction", {});
  expect(scope.isDone()).toBe(true);
});

2. Missing Documentation

The PR doesn't include updates to documentation or JSDoc comments for the new parameter.

Recommendation: Update the JSDoc comment for createClient to include:

* @param {string} [config.functionsVersion] - Optional version identifier for function routing

🟢 Code Quality

The code quality is excellent:

  • ✅ Follows existing patterns and conventions
  • ✅ Uses proper TypeScript typing
  • ✅ Maintains clean separation of concerns
  • ✅ No code duplication

🟢 Performance

The implementation has minimal performance impact:

  • ✅ Only creates different headers when functionsVersion is provided
  • ✅ No additional API calls or processing overhead
  • ✅ Efficient conditional header assignment

🟢 Security

No security concerns identified:

  • ✅ The version header is passed through without manipulation
  • ✅ No sensitive data exposure
  • ✅ Maintains existing authentication patterns

🔵 Additional Observations

  1. Missing Context: The PR mentions extractSnapshotIdFromHost() utility in the description, but this function is not present in the current changes. It appears this was removed in commit 9bbb646 ("revert functions only changes").

  2. Null Coalescing: The use of functionsVersion ?? undefined in line 197 is redundant since null ?? undefined returns undefined. You could simply use functionsVersion directly, but this doesn't affect functionality.


📋 Recommendations

  1. High Priority: Add comprehensive test coverage for the versioning functionality
  2. Medium Priority: Update JSDoc documentation for the new parameter
  3. Low Priority: Consider adding a brief comment explaining the purpose of function versioning for future maintainers

Once test coverage is added, this implementation is solid and ready for production use. The code is clean, follows best practices, and integrates well with the existing SDK architecture.

@base44 base44 deleted a comment from claude bot Sep 10, 2025
@base44 base44 deleted a comment from claude bot Sep 10, 2025
@GabiGrin GabiGrin merged commit c70d1ab into main Sep 10, 2025
4 checks passed
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.

2 participants