-
Notifications
You must be signed in to change notification settings - Fork 2
Add VuMark Generation API endpoint (#473) #2878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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>
There was a problem hiding this 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 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| # Add text | ||
| draw.text(xy=(100, 80), text="VuMark Mock", fill="black") | ||
| draw.text(xy=(100, 110), text=instance_id[:20], fill="black") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PNG image has invisible content due to colors
Medium Severity
The generate_png function creates a black image using Image.new(mode="RGB", size=(200, 200)) (defaults to color 0, which is black), then draws the border and text using fill="black". This results in black text on a black background, making the VuMark mock content completely invisible in the generated PNG.
| trailer | ||
| << /Size 6 /Root 1 0 R >> | ||
| startxref | ||
| 496 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PDF has hardcoded length mismatching variable content
Medium Severity
The generate_pdf function hardcodes /Length 100 for the stream object, but the actual stream content length varies with instance_id. Similarly, the xref byte offsets (lines 103-108) and startxref 496 are hardcoded but shift when instance_id changes length. This produces technically malformed PDFs that may fail to render correctly in strict PDF readers.
| '<text x="100" y="90" text-anchor="middle" font-family="Arial" ' | ||
| 'font-size="14">VuMark Mock</text>' | ||
| '<text x="100" y="120" text-anchor="middle" font-family="monospace" ' | ||
| f'font-size="10">{instance_id}</text>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SVG output is malformed for special character inputs
Low Severity
The generate_svg function inserts instance_id directly into XML content without escaping XML special characters. If instance_id contains <, >, or &, the generated SVG is malformed and will fail to parse. For example, an instance_id of "test<value>" produces invalid XML structure.
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>
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
Introduces VuMark instance generation across both Flask and requests-mock servers.
POST /targets/<target_id>/instancesto generate instance images (image/svg+xml,image/png,application/pdf), with content produced bymock_vws._vumark_generatorsmock_vws._vumark_validatorsforAcceptheader andinstance_id; integrates with key/target validators to requireinstance_idand correctly resolvetarget_idon/instancespathsINVALID_INSTANCE_IDandINVALID_ACCEPT_HEADERand corresponding exceptions; updates requests-mock_ResponseTypeto allowbytesbodies and sets appropriate response headers (includingContent-Length)tests/mock_vws/test_vumark_generation.pycovering success paths, invalid headers/IDs, and response headers@routeto vulture ignores andsvgto spelling dictionaryWritten by Cursor Bugbot for commit f193a40. This will update automatically on new commits. Configure here.