Skip to content

fix: signal unreadable dimensions in create_document - #93

Open
loonghao wants to merge 1 commit into
mainfrom
task/create-document-fe50cfb2d0c1
Open

loonghao wants to merge 1 commit into
mainfrom
task/create-document-fe50cfb2d0c1

Conversation

@loonghao

Copy link
Copy Markdown
Owner

create_document silently fell back to the size the caller requested when Photoshop did not report the new document's width/height, while still returning success: True. A client could not tell a confirmed measurement apart from the size it merely asked for — the same trap that photoshop://document/info and photoshop_open_document were fixed for in #92, at the third entry point.

This uses the try_float/UNCONVERTIBLE helper those two call sites already use:

  • A readable measurement is returned as before, with no extra field.
  • An unreadable measurement sets dimensions_unavailable: true while width/height stay numeric. The fallback is the requested size rather than 0.0, which is a better stand-in for a document just created at that size.
  • The broad except branch, which also falls back to the requested size after a failed property read, carries the same signal for the same reason.

Purely additive: the new field only appears when dimensions cannot be read, so consumers that ignore unknown keys are unaffected. A genuine zero is still reported as 0.0 and is not flagged.

Tests cover the readable, unreadable, UnitValue, genuine-zero and property-read-failure branches; the unreadable cases fail against the previous implementation.

When Photoshop did not report the new document's width/height,
create_document silently fell back to the size the caller requested
and still returned success: True. A client could not tell a confirmed
measurement apart from the size it merely asked for.

Use the try_float/UNCONVERTIBLE helper that document/info and
open_document already use. An unreadable dimension now sets
dimensions_unavailable: true while width/height stay numeric, falling
back to the requested size rather than 0.0 - a better stand-in for a
document just created at that size. The except-branch fallback carries
the same signal for the same reason.

Adds coverage for the readable, unreadable, UnitValue, genuine-zero and
property-read-failure branches.
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.

1 participant