Skip to content

feat(tasks): let a queue refuse a config when it is saved - #2179

Merged
c-thiel merged 1 commit into
mainfrom
ct/task-config-check-on-save
Oct 25, 2026
Merged

c-thiel merged 1 commit into
mainfrom
ct/task-config-check-on-save

Conversation

@c-thiel

@c-thiel c-thiel commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Adds TaskConfig::check_config, an extension point that lets a task queue refuse a config when it is saved through POST /management/v1/warehouse/{warehouse_id}/task-queue/{queue_name}/config or POST /management/v1/project/task-queue/{queue_name}/config.

The check runs after authz and after the config is parsed, before the write. Its error (typically 400 with a queue-specific type and message) is returned unchanged, and nothing is stored. Implementations should name the setting to change in the message.

User-visible change

None for the built-in queues: they keep the default, which accepts every config that parses.

Downstream queues can override check_config to refuse values their worker would reject at pickup, so the operator gets the error when saving instead of a failed task later. Configs stored earlier are not re-checked, so a queue keeps its own check at pickup.

API

The change is additive:

  • TaskConfig::check_config, a default method on both trait variants (with and without open-api)
  • ConfigCheckFn and RegisteredTaskQueues::config_check_fn, next to the existing validate_config_fn, payload_validator_fn and schedule_eligibility_fn

check_config and check_schedule_eligibility now share one helper that parses the stored config. The error text and type are unchanged.

Tests

  • Registry unit test: a queue that refuses one value returns the exact 400 type and message for it and accepts another value.
  • API test against Postgres, warehouse route: an accepted config is stored. A refused config returns the exact 400, and the previous config is unchanged.
  • API test against Postgres, project route: a refused config returns the same 400, and nothing is stored.

Summary by CodeRabbit

  • Bug Fixes
    • Invalid task queue configurations are now rejected when saved, with an error explaining the validation failure.
    • Rejected updates leave the existing warehouse configuration unchanged, and invalid project configurations do not replace the default.

Add `TaskConfig::check_config`, a default method that accepts every config. The task-queue config endpoint, at warehouse and project scope, calls it after the config is parsed and before anything is stored, and returns its error unchanged. A queue can now refuse a config its worker would reject at pickup, so the operator sees the problem when saving. Built-in queues keep the default, so their behaviour does not change.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5066be7c-260b-4022-9c0a-2bb56c5d6a85
Commits

Reviewing files that changed from the base of the PR and between 7b9e47c and 8a92aee.

Files selected for processing: 4
  • crates/lakekeeper-integration-tests/tests/management_tasks_schedule_lifecycle.rs
  • crates/lakekeeper/src/api/management/v1/task_queue.rs
  • crates/lakekeeper/src/service/tasks/mod.rs
  • crates/lakekeeper/src/service/tasks/task_registry.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Task queue configurations now support an optional validation hook. The management API invokes the hook before starting a write transaction. Tests cover accepted and rejected configurations at warehouse and project scope.

Changes

Task queue configuration validation

Layer / File(s) Summary
Define and register the validation hook
crates/lakekeeper/src/service/tasks/mod.rs, crates/lakekeeper/src/service/tasks/task_registry.rs
TaskConfig adds a default check_config method. The registry exposes a callback that parses queue configuration and invokes the method. A registry test covers accepted and rejected values.
Validate configurations before saving
crates/lakekeeper/src/api/management/v1/task_queue.rs, crates/lakekeeper-integration-tests/tests/management_tasks_schedule_lifecycle.rs
The management API invokes the callback before starting a write transaction. Integration tests verify warehouse and project configuration behavior, including retained values after rejected updates.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant TaskQueueAPI
  participant RegisteredTaskQueues
  participant ConfigCheckCallback
  participant TaskConfig
  participant WriteTransaction
  TaskQueueAPI->>RegisteredTaskQueues: Look up queue config-check callback
  RegisteredTaskQueues-->>TaskQueueAPI: Return optional callback
  TaskQueueAPI->>ConfigCheckCallback: Validate submitted JSON config
  ConfigCheckCallback->>TaskConfig: Parse config and call check_config
  TaskConfig-->>ConfigCheckCallback: Return validation result
  ConfigCheckCallback-->>TaskQueueAPI: Return validation result
  TaskQueueAPI->>WriteTransaction: Start transaction if validation succeeds
Loading

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to 8a92a

Both configuration routes validate the value they save, and rejected values are not written. The change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: queues can reject task configurations when they are saved.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each queue with care,
A level zero stops right there.
A valid level passes through,
The saved config stays as it should.
Then hops the rabbit, pleased and bright.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit 8d47ab1 into main Oct 25, 2026
76 of 77 checks passed
@c-thiel
c-thiel deleted the ct/task-config-check-on-save branch October 25, 2026 10:04
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