Repository navigation
fix(server): check printer, key and quota before fetching a payload; version 3.4.0 - #12
Merged
Merged
Conversation
…ing a payload Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
…guard, gate fixes - PRINTAPI_FETCHES_PER_ORG (0 = no cap); unset: 4 with open signup, else no cap - label_base64 takes no download slot - key lookup and quota check in one DB closure - an idempotency key being fetched answers 409 to a second request - label_uri answers 503 before the fetch when no render slot is free - docs and comments follow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #11, found by its security review. Before this change, a
*_urijob made the server fetch its URL before it checked the printer and the quota. An org with quota 0 and no printer could make the server send unlimited outbound requests, none of which counted against the quota, and could hold all 256 outbound slots with a slow URL. The label path checked first, but only for jobs without anidempotency_key.What changes
For every job type the server fetches (
raw_uri,pdf_uri,raw_uri_post,pdf_uri_post,label_uri), four checks now run before the fetch, in this order:idempotency_key. A resubmit returns the original job without fetching again. While a request with a key is still in flight, a concurrent one with the same key gets 409, so a*_uri_postnever hits its downstream service twice.PRINTAPI_FETCHES_PER_ORG. It defaults to 4 withPRINTAPI_SIGNUP=openand to no cap otherwise, so a single-org self-hosted box keeps today's behaviour. Over the cap the answer is 503.Smaller fixes:
label_urianswers 503 before fetching when no render slot is free.label_base64andlabel_texttake no download slot.*_base64) keep their order of checks exactly.enqueue_jobkeeps its own checks inside the write transaction. The new checks only stop the expensive work earlier.Docs:
docs/api.md,docs/labels.md(order of checks and errors),docs/printnode-compat.md,docs/server.md(env row).This PR also sets the version to 3.4.0 for the release that follows, which covers #11 and this PR.
Review
An adversarial review plus a Codex adversarial review (read-only) checked the change, and an independent verifier checked every finding. Six were confirmed and fixed in ab1d678. The most important: a hardcoded per-org cap would have let four hung upstream fetches block every label of a single-org production box. Three Codex findings were refuted as not caused by this change (the global pool shared by many orgs, the private-URL default, failed fetches not counting as quota).
Checks (local, at 3c22f74)
cargo test --workspace: 910 passed.crates/setup: 106 passed. Clippy-D warningsandfmt --checkare clean.--db-compat: 23/23.pytest tools/docs,check_docs.py,pytest agent/tests, and weblint,testandcheck:bundlespass.🤖 Generated with Claude Code
https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX