Skip to content

fix: always send variables field in function run/schedule requests#17

Merged
giordano-lucas merged 1 commit intomainfrom
fix/functions-require-variables
Mar 16, 2026
Merged

fix: always send variables field in function run/schedule requests#17
giordano-lucas merged 1 commit intomainfrom
fix/functions-require-variables

Conversation

@giordano-lucas
Copy link
Copy Markdown
Member

@giordano-lucas giordano-lucas commented Mar 16, 2026

Summary

  • Always include variables field (as {} when empty) in the functions run request body — the API now requires it
  • Set Variables to an empty map on functions schedule request body so it's serialized instead of omitted

Fixes 3 integration test failures: TestFunctionIDResolution, TestFunctionRun, TestFunctionsScheduleAndUnschedule

Test plan

  • Verify notte functions run works without --var/--vars flags
  • Verify notte functions run --var key=value still works
  • Verify notte functions schedule works
  • Integration tests pass in CI

🤖 Generated with Claude Code

Greptile Summary

This PR fixes two API serialization issues where required fields were being omitted from request bodies, causing integration test failures.

  • runFunctionRun: Removes the len(variables) > 0 guard so "variables" is always serialized (as {} when no variables are provided), matching the API's requirement.
  • runFunctionSchedule: Initializes Variables to &emptyVars (a pointer to an empty map[string]interface{}) so the field is serialized as "variables": {} instead of being omitted due to the omitempty JSON tag on the *map[string]interface{} pointer.

Confidence Score: 5/5

  • This PR is safe to merge — it makes minimal, targeted fixes to ensure required API fields are always serialized.
  • The changes are small, well-scoped, and correct. variables in runFunctionRun was already initialized to an empty map, so always including it is a safe no-op when no variables are provided. In runFunctionSchedule, assigning a non-nil pointer to Variables correctly forces JSON serialization despite the omitempty tag. No logic is altered beyond ensuring the fields are present in the serialized body.
  • No files require special attention.

Important Files Changed

Filename Overview
internal/cmd/functions.go Always includes variables field in function run request body and initializes Variables to an empty map pointer for schedule requests so it is serialized rather than omitted.

Last reviewed commit: 2641b15

The API now requires the `variables` field in the request body. Previously
it was only included when the user explicitly provided variables via flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@giordano-lucas giordano-lucas merged commit 43924ca into main Mar 16, 2026
3 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