Skip to content

chore(assessment): Video Integration - #1211

Merged
vprashrex merged 7 commits into
mainfrom
feat/assessment-video-input
Sep 29, 2026
Merged

vprashrex merged 7 commits into
mainfrom
feat/assessment-video-input

Conversation

@vprashrex

@vprashrex vprashrex commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #1212

Summary

  • Before: Assessment BATCH input columns supported only image/pdf attachments; Gemini video inputs (incl. YouTube URLs) weren't supported.
  • Now: Added a video input-column type — routed to Gemini's fileData video parts, with OpenAI/Anthropic skipping video cells instead of erroring (video is Google-only).

Checklist

  • Ran fastapi run --reload app/main.py and tested.
  • No behavior change for image/pdf columns.

Notes

OpenAI/Anthropic don't support video attachments upstream.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: ProjectTech4DevAI/kaapi-backend/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 9d24b715-218e-4da8-a747-0b2ac811b1bc

📥 Commits

Reviewing files that changed from the base of the PR and between d318a8f and 175bb9e.

📒 Files selected for processing (11)
  • backend/app/crud/assessment/batch.py
  • backend/app/models/assessment/assessment.py
  • backend/app/models/config/assessment_blob.py
  • backend/app/services/assessment/api/batch.py
  • backend/app/services/assessment/api/submission.py
  • backend/app/services/assessment/utils/attachments.py
  • backend/app/services/llm/mappers.py
  • backend/app/tests/assessment/test_api_crud.py
  • backend/app/tests/assessment/test_batch.py
  • backend/app/tests/services/llm/test_mappers.py
  • docs/wiki/modules/assessment.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: ProjectTech4DevAI/kaapi-backend/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e6b1581c-f959-416e-b0d4-0e245565b72e

📥 Commits

Reviewing files that changed from the base of the PR and between 160e2b2 and d318a8f.

📒 Files selected for processing (3)
  • backend/app/tests/assessment/test_api_crud.py
  • backend/app/tests/assessment/test_batch.py
  • backend/app/tests/services/llm/test_mappers.py

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


📝 Walkthrough

Walkthrough

Assessment inputs now accept video attachments. Attachment validation and provider builders handle video values. Google batch generation creates Gemini video parts with video-related configuration.

Changes

Video attachments

Layer / File(s) Summary
Video attachment schema and validation
backend/app/models/assessment/assessment.py, backend/app/models/config/assessment_blob.py, backend/app/services/assessment/api/batch.py, backend/app/services/assessment/api/submission.py, backend/app/tests/assessment/test_api_crud.py, docs/wiki/modules/assessment.md
Assessment models accept video attachment types. Input columns reject video with base64 format. Submission validation recognizes common video extensions and applies attachment checks to video columns. Tests cover the format validation, and the documentation describes URL format requirements and provider behavior.
Provider attachment part handling
backend/app/services/assessment/utils/attachments.py, backend/app/tests/assessment/test_batch.py
Attachment type resolution accepts configured attachment types. OpenAI and Anthropic builders skip video values. The Gemini builder creates video fileData parts, infers MIME types from URL extensions, omits mimeType for recognized YouTube hosts, and accepts optional video-part configuration. Tests cover provider handling and MIME behavior.
Google video batch generation
backend/app/services/llm/mappers.py, backend/app/crud/assessment/batch.py, backend/app/tests/services/llm/test_mappers.py, backend/app/tests/assessment/test_batch.py
The Google parameter mapper supplies video-part and media-resolution defaults. Batch generation passes video-part configuration to Gemini and adds mediaResolution when a row contains a video attachment. Tests cover the defaults and batch generation.

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant GoogleParamsMapper
  participant build_google_jsonl
  participant build_gemini_attachment_parts
  GoogleParamsMapper->>build_google_jsonl: video_part_config and media_resolution defaults
  build_google_jsonl->>build_gemini_attachment_parts: resolved video type and video_part_config
  build_gemini_attachment_parts-->>build_google_jsonl: Gemini video fileData part
Loading

Merge Risk: ⚪ Minimal · up to d318a

YouTube links pass submission validation. The available evidence establishes no specific failure that warrants delaying merge.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to d318a

Video submissions can reach Google for processing, while other supported providers may process a row without its video or fail after accepting it. No authentication bypass was established, but those differences warrant design review.

Retained concerns

  • Medium · reliability · inferred: Accepted video rows can lose their video content on OpenAI or Anthropic stages. Video-only rows can be omitted from the generated batch despite being counted at submission; rows with text can produce an assessment without the video.
  • Low · reliability · inferred: The external-dataset attachment contract accepts video/base64, but the legacy batch path constructs video parts from cell values as URLs. Unlike the newer input-column path, its URL-only precondition is not established before dispatch.
Security review details

Security Blast Radius

  • inferred — An authorized assessment submitter can supply a video URL to a Google-configured assessment, extending the existing attachment-to-provider data boundary to video. No new unauthenticated entrypoint or cross-tenant credential selection was established.

Trust Boundaries and Controls

  • observed — Submission validation checks URL prefixes and recognizable extension mismatches, not destination hosts. The application passes ordinary video URLs to Google rather than fetching them in the inspected builder; provider-side fetching restrictions remain unknown.

Resilience and Maintainability Implications

  • inferred — Silently omitting video on unsupported providers can make assessment results appear to cover an accepted input they did not examine; whether any downstream security decision depends on those results is not established.

Hardening Proposals

  • proposed — Define an explicit policy for video URL destinations and provider capability at submission time, so accepted assessments have a predictable external-data boundary and cannot imply that an omitted video was evaluated.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements the main video objectives in [#1212]. It adds the video schema type, URL validation for InputColumn, video extension detection, Gemini video parts, Google video parameters, and O… Update AssessmentAttachment validation to reject format='base64' for type='video' and for mixed attachments whose type_value_map includes video. Add automated tests for both validation cases.
Docstring Coverage ⚠️ Warning Docstring coverage is 46.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: video integration for assessments. It is concise and related to the changeset.
Description check ✅ Passed The description accurately summarizes video input support, Gemini handling, provider limitations, testing, and unchanged image/PDF behavior.
Out of Scope Changes check ✅ Passed The changes stay within [#1212]. The shared attachment types, video extension detection, provider-specific skipping, Gemini part construction, Google parameter mapping, tests, and documentation suppor…
Full details: Linked Issues check

Explanation

The PR implements the main video objectives in [#1212]. It adds the video schema type, URL validation for InputColumn, video extension detection, Gemini video parts, Google video parameters, and OpenAI/Anthropic skipping. However, AssessmentAttachment.format still permits base64 when type is video. It also permits base64 for mixed attachments whose type_value_map contains video. The current validator only checks the required fields for mixed.

✨ 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

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.

@github-actions github-actions Bot changed the title chore(Assessment): Video Integration feat(assessment): Enhance video handling support Sep 29, 2026
@vprashrex vprashrex changed the title feat(assessment): Enhance video handling support chore(assessment): Video Integration Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main ↔ 2143d255 · generated by oasdiff

@vprashrex vprashrex self-assigned this Sep 29, 2026
@vprashrex vprashrex added enhancement New feature or request ready-for-review labels Sep 29, 2026
@vprashrex
vprashrex requested a review from Ayush8923 September 29, 2026 12:53
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.87640% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ckend/app/services/assessment/utils/attachments.py 97.14% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Ayush8923

Copy link
Copy Markdown
Collaborator

@vprashrex codecov report is failing, please check and fix it.

@Ayush8923 Ayush8923 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved with a few comments, mainly from a usability perspective.


def build_gemini_video_part(
url: str, video_part_config: dict[str, Any] | None = None
) -> dict[str, Any]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we avoid using Any here and add proper type safety instead, if you already know what this dictionary contains? and please make all these updates everywhere in this PR.

model_config = {"extra": "forbid"}

type: Literal["text", "image", "pdf"]
type: Literal["text", "image", "pdf", "video"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we use the related constant here too? and maybe bit cleaner approach.

ColumnType = Literal[
    "text",
    IMAGE_COLUMN_TYPE,
    PDF_COLUMN_TYPE,
    VIDEO_COLUMN_TYPE,
]

then

type: ColumnType

)
type_value_map: dict[str, Literal["image", "pdf"]] | None = Field(
None, description="'mixed' only: maps a type_column value to 'image' or 'pdf'"
type_value_map: dict[str, Literal["image", "pdf", "video"]] | None = Field(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we use the same attachment constant here as well? we could define a common constant for the shared values and reuse it everywhere, then append the additional values where needed.

@vprashrex

Copy link
Copy Markdown
Collaborator Author

@vprashrex codecov report is failing, please check and fix it.

codecov coverage is fixed

@vprashrex vprashrex added the breaking-change-approved Reviewer-acknowledged API breaking change label Sep 29, 2026
@vprashrex

Copy link
Copy Markdown
Collaborator Author

Adding breaking-change-approved — the flagged breaking changes are a schema-shape artifact, not an actual contract change.

AssessmentAttachment.type now reuses the shared AttachmentColumnType literal instead of redeclaring the values, so the generated schema became an anyOf instead of a flat enum:

// before
{ "enum": ["image", "pdf", "video", "mixed"], "type": "string" }

// after
{ "anyOf": [
    { "enum": ["image", "pdf", "video"], "type": "string" },
    { "const": "mixed", "type": "string" }
]}

oasdiff looks for enum at the property level, doesn't find one, and reports every value as removed. The accepted values are unchanged (image/pdf/video/mixed) and validation still rejects anything else.

Also, /api/v1/assessment/runs isn't in use, so there are no downstream consumers affected here.

@vprashrex
vprashrex enabled auto-merge (squash) September 29, 2026 14:43
@vprashrex
vprashrex merged commit 2143d25 into main Sep 29, 2026
6 checks passed
@vprashrex
vprashrex deleted the feat/assessment-video-input branch September 29, 2026 14:55
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.7.0-main.12 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change-approved Reviewer-acknowledged API breaking change released on @main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assessment: Support video attachments

2 participants