Skip to content

fix: AE-2316: field validator for serverless idleTimeout#287

Merged
jhcipar merged 1 commit intomainfrom
jhcipar/AE-2316/idletimeout-validation
Mar 26, 2026
Merged

fix: AE-2316: field validator for serverless idleTimeout#287
jhcipar merged 1 commit intomainfrom
jhcipar/AE-2316/idletimeout-validation

Conversation

@jhcipar
Copy link
Copy Markdown
Contributor

@jhcipar jhcipar commented Mar 25, 2026

adds a field validator to idleTimeout so errors happen at construction time rather than deploy time; backend currently restricts idleTimeout to between 1 and 3600s.

@jhcipar jhcipar changed the title fix: AE-2316: idletimeout must be in valid range fix: AE-2316: field validator for serverless idleTimeout Mar 25, 2026
@promptless
Copy link
Copy Markdown

promptless bot commented Mar 25, 2026

📝 Documentation updates detected!

New suggestion: Document valid range for idle_timeout parameter


Tip: Filter the Dashboard by labels or assignees to focus on what matters to you 🔎

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds construction-time validation for the idleTimeout field on serverless endpoints to match backend constraints (1–3600 seconds), preventing invalid configs from failing later at deploy time.

Changes:

  • Add a Pydantic field_validator for idleTimeout in ServerlessResource.
  • Add unit tests covering invalid and boundary-valid idleTimeout values for ServerlessResource.
  • Add a unit test confirming LiveServerless rejects an invalid idleTimeout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/runpod_flash/core/resources/serverless.py Enforces idleTimeout range (1–3600) during model construction via field_validator.
tests/unit/resources/test_serverless.py Adds parametrized tests for invalid values and valid boundary values.
tests/unit/resources/test_live_serverless.py Adds a regression test ensuring LiveServerless inherits/enforces the idleTimeout validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deanq deanq requested review from KAJdev and deanq March 25, 2026 23:44
Copy link
Copy Markdown
Contributor

@runpod-Henrik runpod-Henrik left a comment

Choose a reason for hiding this comment

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

  1. Validator correctness and placement
    The validator is placed on ServerlessResource, which is the common base for all concrete resource types. A single validator here covers the entire hierarchy. The bounds 1 <= value <= 3600 match the stated backend restriction. The default of 60 falls within the valid range. The None pass-through is correct.

  2. Error timing for Endpoint users
    The PR description says "errors happen at construction time rather than deploy time." This is true for direct ServerlessResource use. For Endpoint users (@endpoint(idle_timeout=...)), the error fires at decoration time — still much better than deploy time, and acceptable behavior.

  3. Test coverage
    test_serverless.py has good parametric coverage: [0, -1, 3601] for rejection and [1, 3600] for boundary acceptance.

test_live_serverless.py adds only a single test (idleTimeout=0). Missing: upper bound rejection (3601) and valid boundary acceptance (1, 3600). Since LiveServerless inherits the validator with no override, the gap is low risk, but inconsistent with the base-class test pattern established in this same PR.

  1. Missing Endpoint-level unit test
    The new unit tests exercise ServerlessResource and LiveServerless directly. There is no unit-level test for Endpoint(idle_timeout=0) or Endpoint(idle_timeout=3601) raising ValueError. A companion test in test_endpoint.py would complete the coverage.

Nits
Error message says "idleTimeout must be between 1 and 3600 seconds" — camelCase matches other validators in the file. Consistent.
Verdict
PASS WITH NITS — validator is correct, placement covers the full class hierarchy, and bounds match the stated backend constraint. The test_live_serverless.py addition only tests one of the three rejection cases covered in test_serverless.py; rounding it out would be a small improvement.

🤖 Reviewed by Henrik's AI-Powered Bug Finder

@jhcipar jhcipar merged commit 57aebbf into main Mar 26, 2026
8 checks passed
@jhcipar jhcipar deleted the jhcipar/AE-2316/idletimeout-validation branch March 26, 2026 23:42
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.

5 participants