Skip to content

fix: resolve ValidationError in DetectionSchema due to missing center#165

Open
Deepthit-23 wants to merge 4 commits into
Devnil434:mainfrom
Deepthit-23:fix-detection-schema-center
Open

fix: resolve ValidationError in DetectionSchema due to missing center#165
Deepthit-23 wants to merge 4 commits into
Devnil434:mainfrom
Deepthit-23:fix-detection-schema-center

Conversation

@Deepthit-23

@Deepthit-23 Deepthit-23 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Resolves the ValidationError raised when instantiating DetectionSchema without the center field (which is required by the Pydantic schema but calculated by BoundingBox.center property).

Changes

  • Modified libs/schemas/detection.py to make center field optional.
  • Added a @model_validator(mode="after") to automatically compute center from bbox if not provided.

Verification

Ran pytest tests/test_detector.py and verified all tests pass successfully.

Closes #158

Summary by CodeRabbit

  • New Features

    • Detection center coordinates are now automatically derived from bounding box data when not explicitly provided.
  • Chores

    • Updated development dependencies.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Deepthit-23, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: faedb92c-a4ab-4182-8bd4-9df3c17609ff

📥 Commits

Reviewing files that changed from the base of the PR and between 7d1cd54 and 7320176.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • services/detection/requirements.txt
📝 Walkthrough

Walkthrough

DetectionSchema.center is changed from a required field to an optional one defaulting to None, and a @model_validator(mode="after") method populate_center is added to auto-derive center from bbox.center when not explicitly provided. Additionally, the black dev dependency minimum version is bumped from >=23.0.0 to >=26.3.1.

Changes

DetectionSchema center auto-derivation

Layer / File(s) Summary
Optional center field and populate_center validator
libs/schemas/detection.py
Imports model_validator, changes DetectionSchema.center from a required tuple[float, float] to Optional[tuple[float, float]] defaulting to None, and adds the populate_center post-validator that reads bbox.center to fill in the value when it is absent.

Dev dependency version bump

Layer / File(s) Summary
black version constraint
pyproject.toml
Updates the black dev dependency lower bound from >=23.0.0 to >=26.3.1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A center once required, now free to roam,
derived from bbox — no need to be told at home!
The validator hops in, after fields are set,
computing (cx, cy) — the easiest fix yet.
And black gets a bump, fresh coat on the hutch,
a small tidy change that doesn't ask much! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The black dependency update (CVE-2026-32274) is a security fix that, while unrelated to the main DetectionSchema change, is a legitimate out-of-scope addition. Move the black dependency update to a separate PR focused on security patches, or clarify the security rationale in PR documentation for dependency changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making the center field optional and automatically computed from bbox in DetectionSchema.
Linked Issues check ✅ Passed The PR fully addresses issue #158 by making center optional and adding a validator to auto-compute it from bbox, resolving the ValidationError.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

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.

[Bug]: ValidationError in DetectionSchema due to required center field

1 participant