Repository navigation
Signal unreadable document dimensions in document/info and open_document - #92
Merged
Merged
Conversation
…_document When Photoshop does not report a document's width/height, both the `photoshop://document/info` resource and the `photoshop_open_document` tool silently collapsed them to 0.0, leaving clients unable to tell a genuine zero apart from an unreadable measurement. Add a `try_float` helper alongside `to_float` that returns an UNCONVERTIBLE sentinel instead of a stand-in number, and use it at the two call sites. When either dimension is unreadable the payload now carries `dimensions_unavailable: true` while width/height stay numeric. The field is only present when dimensions cannot be read, so existing consumers that ignore unknown keys are unaffected.
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.
Problem
Document.width/Document.heightare read throughto_float(), which collapses anyunconvertible value into its
default(0.0) and only leaves alogger.warning. A clienttherefore cannot distinguish a document that is genuinely zero-sized from one whose
dimensions Photoshop never reported — the symptom reported in issue #55 stayed invisible
rather than fixed.
Change
try_float()next toto_float(). It applies the same conversion rules but returnsan
UNCONVERTIBLEsentinel instead of a stand-in number, so callers can tell a real0.0apart from an unreadable measurement. The warning log is kept.
photoshop://document/infoand thephotoshop_open_documenttool now usetry_float().When either dimension is unreadable, the payload gains
dimensions_unavailable: truewhile
width/heightremain numeric (0.0).to_float()and thecreate_documentcall site are unchanged.Payload contract
This is an additive, non-breaking change. The new field is only present when dimensions
cannot be read, so consumers that ignore unknown keys see the exact same payload shape as
before. Existing fields (
name,width,height,resolution,layers_count,success,document_name) are never removed or renamed.Tests
Extended
tests/unit/test_dimension_utils.py, reusing the existing host-free fakes:try_floatbehaviour (including that a genuine0is not the sentinel); both branches forthe
photoshop://document/inforesource and thephotoshop_open_documenttool; readablevalues as plain float and as
UnitValue; unreadable values as opaque objects,None, and aUnitValuewith a non-numeric.value; and a genuine zero that must stay unflagged.Verified with
pytest tests/unit -q.Note
tests/unit/test_stdio_log_pollution.py::test_stdio_session_stdout_is_pure_jsonrpcisintermittently flaky on this machine independent of this change — it fails roughly 1 run in
8 on an unmodified
maincheckout, since it asserts on the output of a subprocess session.Reproduced before touching any code; not addressed here.