Skip to content

Add VuMark Generation API endpoint (#473)#2878

Open
adamtheturtle wants to merge 13 commits intomainfrom
adamtheturtle/remove-mock-prefix
Open

Add VuMark Generation API endpoint (#473)#2878
adamtheturtle wants to merge 13 commits intomainfrom
adamtheturtle/remove-mock-prefix

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Jan 28, 2026

Implements POST /targets/<target_id>/instances endpoint for generating VuMark instance images in SVG, PNG, or PDF format. Includes validators, exception classes, image generators, and comprehensive test coverage for both requests-mock and Flask implementations.

Closes #473

🤖 Generated with Claude Code


Note

Medium Risk
Adds a new binary-returning API route and new validation/error paths across both mock backends, plus changes to database/target serialization that could break compatibility if any callers assume the previous schemas.

Overview
Adds support for the VuMark Generation API via POST /targets/<target_id>/instances in both the Flask server and the requests-mock backend, returning placeholder SVG/PNG/PDF content based on the Accept header.

Introduces VuMark-specific validators and new ResultCodes/ValidatorError types for invalid Accept, invalid/missing instance_id, non-vumark target types, and non-success target status; updates key/target-id routing validation to handle the new /instances path shape.

Extends the data model to persist target_type per target and default_target_type per database (configurable via target-manager), and adds comprehensive tests plus CI inclusion for the new endpoint and a regression around target IDs named instances.

Written by Cursor Bugbot for commit b536a1d. This will update automatically on new commits. Configure here.

Implement POST /targets/<target_id>/instances endpoint for generating
VuMark instance images in SVG, PNG, or PDF format. Includes validators,
exception classes, image generators, and comprehensive test coverage for
both requests-mock and Flask implementations.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Address mypy type checking issues in vumark implementation:
- Use keyword arguments for PIL Image/ImageDraw methods
- Add proper type annotation for accept_header variable
- Use str(object=...) syntax for strict type checking

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add 'svg' to spelling dictionary and fix 'pdf' to 'PDF' in comments
to pass pylint spell checking.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Use the standard test pattern with the verify_mock_vuforia fixture so
tests run against all backends (real, mock, docker). Add test classes
to the CI matrix in test.yml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- PNG: Use white background (was black, making text invisible)
- SVG: Escape instance_id with xml.sax.saxutils.escape to prevent
  malformed XML from special characters
- PDF: Compute stream length, xref offsets, and startxref dynamically
  instead of hardcoding them. Escape PDF string literal characters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Return exc.response_text as str (consistent with all other endpoints)
instead of encoding to bytes on error paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Real Vuforia returns 422 InvalidTargetType because the test targets
are regular image targets, not VuMark targets. Use mock_only_vuforia
to skip real Vuforia backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

return requests.post(url=url, data=content, headers=headers, timeout=30)


@pytest.mark.usefixtures("mock_only_vuforia")
Copy link
Member Author

Choose a reason for hiding this comment

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

This needs to not be mock-only

"""Tests for successful VuMark instance generation."""

@pytest.fixture
def vuforia_database( # pylint: disable=no-self-use
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead, let's have a conftest.py fixture for a vucloud dataabse

pyproject.toml Outdated
"@*APP.route",
"@*APP.before_request",
"@*APP.errorhandler",
# requests-mock server
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why we need this

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.

Add VuMark Generation API

1 participant