Skip to content

fix: functions run command with API key header and variable support#41

Merged
giordano-lucas merged 3 commits intomainfrom
fix/functions-run-api-key-and-variables
Feb 4, 2026
Merged

fix: functions run command with API key header and variable support#41
giordano-lucas merged 3 commits intomainfrom
fix/functions-run-api-key-and-variables

Conversation

@giordano-lucas
Copy link
Member

@giordano-lucas giordano-lucas commented Feb 4, 2026

Fixed two critical issues with the 'functions run' command:

  1. Missing x-notte-api-key header - The FunctionRunStartParams required field was not being populated, causing 400 errors
  2. Missing request body - API requires function_id in JSON body but generated client doesn't support it

Added variable support for workflow execution:

  • --var flag for key=value pairs (can be used multiple times)
  • --vars flag for JSON object string
  • Variables are passed to the function run API

Changes:

  • Added APIKey() method to NotteClient
  • Rewrote runFunctionRun to manually construct HTTP request with body
  • Added integration tests for function run and variables
  • Added unit test for APIKey() method

Resolves issue with function run failing with API key validation error

Greptile Overview

Greptile Summary

Fixed critical issues with the functions run command where the generated API client lacked support for required authentication header and request body.

Key Changes:

  • Added method to NotteClient for exposing authentication credentials
  • Rewrote runFunctionRun to manually construct HTTP request with body containing function ID and variables
  • Added support for passing variables through command-line flags (individual pairs or JSON object)
  • Added comprehensive integration and unit tests

The implementation reuses the existing HTTP client for retry logic and circuit breaker functionality.

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations around dual authentication headers
  • The implementation correctly fixes the critical bug and adds comprehensive tests. Score of 4 (not 5) because the manual HTTP request results in dual authentication headers (both Authorization Bearer and x-notte-api-key) being sent, though this should be harmless as the API will use the appropriate header
  • No files require special attention - all changes are well-tested and straightforward

Important Files Changed

Filename Overview
internal/api/client.go Added APIKey() getter method to expose the API key, enabling manual HTTP requests with proper authentication
internal/api/client_test.go Added unit test for APIKey() method, verifying it returns the correct API key
internal/cmd/functions.go Rewrote runFunctionRun to manually construct HTTP request with body containing function_id and variables, added --var and --vars flags for variable support
tests/integration/functions_test.go Added comprehensive integration tests for function run command with and without variables, covering all flag combinations

@giordano-lucas giordano-lucas self-assigned this Feb 4, 2026
@giordano-lucas giordano-lucas force-pushed the fix/functions-run-api-key-and-variables branch from 7d4574e to 763a3f0 Compare February 4, 2026 14:07
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Fixed two critical issues with the 'functions run' command:

1. Missing x-notte-api-key header - The FunctionRunStartParams required
   field was not being populated, causing 400 errors
2. Missing request body - API requires function_id in JSON body but
   generated client doesn't support it

Added variable support for workflow execution:
- --var flag for key=value pairs (can be used multiple times)
- --vars flag for JSON object string
- Variables are passed to the function run API

Changes:
- Added APIKey() method to NotteClient
- Rewrote runFunctionRun to manually construct HTTP request with body
- Added integration tests for function run and variables
- Added unit test for APIKey() method

Resolves issue with function run failing with API key validation error
@giordano-lucas giordano-lucas force-pushed the fix/functions-run-api-key-and-variables branch from 763a3f0 to 2ba4a92 Compare February 4, 2026 14:09
- Upgrade to golangci-lint v2 to match CI configuration
- Fix errcheck issue: properly handle httpResp.Body.Close() error
- Fix gofumpt formatting issues in functions.go
- Update make lint to suppress cache warnings
- Update make pre-commit-run to run full lint on all code
- Fix staticcheck SA5011 in client_test.go by removing redundant nil check
@giordano-lucas giordano-lucas merged commit 3c893f3 into main Feb 4, 2026
6 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.

1 participant