Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Synse
Copy link
Contributor

@Synse Synse commented Jun 12, 2025

This PR resolves an exception when querying connected_displays if one or more displays are rotated.

The content of spdisplays_rotation is "spdisplays_supported" when rotation is supported but the display is not rotated (i.e., 0 degree rotation) and either 90, 180, or 270 when the display is rotated. An example of both cases is available here.

🐛 The bug

When querying connected_displays if any display is rotated a uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance is raised because of the isEqualToString check here.

The documentation for the rotation field says it should be the rotation of the monitor but it's currently implemented as 1 when rotation is supported and 0 when it isn't supported.

The implementation proposed here changes that to be 0 for supported but not rotated, 90/180/270 if rotated, otherwise null. The table documentation should also be updated if this moves forward.

💭 Questions

  • Should rotation be the degree rotation of the monitor, or should it indicate whether rotation is (or is not) supported?
  • This is my first OSQuery PR, is there a good example of mocking both cases in the tests? Currently only the type is being checked? 😿

📚 References

Copy link

linux-foundation-easycla bot commented Jun 12, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@Synse Synse marked this pull request as ready for review June 12, 2025 22:02
@Synse Synse requested review from a team as code owners June 12, 2025 22:02
@zwass
Copy link
Member

zwass commented Jun 18, 2025

Nice, thank you.

Should rotation be the degree rotation of the monitor, or should it indicate whether rotation is (or is not) supported?

I'm guessing you have a use case here. What would be best for you?

This is my first OSQuery PR, is there a good example of mocking both cases in the tests?

Not that I can think of. Generally we try to do some manual testing against a few different configurations and then make sure it at least returns some sort of sane result in the automated testing/on CI.

@Synse
Copy link
Contributor Author

Synse commented Jun 18, 2025

Should rotation be the degree rotation of the monitor, or should it indicate whether rotation is (or is not) supported?

I'm guessing you have a use case here. What would be best for you?

I don't have a specific use case for the rotation value, I'm just looking to query these tables without osqueryd crashing. 😅

That said, I think that having the degree rotation (0/90/180/270) would be useful to some. Its still possible to infer if rotation is supported (or not): -1 would be unsupported, anything else would be supported.

@Synse
Copy link
Contributor Author

Synse commented Jun 18, 2025

abadaf7 should resolve the failing test, by returning -1 for unsupported rotation (instead of ""):

82: [----------] 1 test from connectedDisplays
82: [ RUN      ] connectedDisplays.test_sanity
82: 2025-06-18 03:16:20.743 system_profiler[8992:43550] Device PreExisted [00000001000002f4] Apple Paravirtual device
82: /Users/runner/work/osquery/osquery/workspace/src/tests/integration/tables/helper.cpp:167: Failure
82: Value of: validate_value_using_flags(value, flags)
82:   Actual: false
82: Expected: true
82: Standard validator of the column "rotation" with value "" failed
82: Row: {ambient_brightness_enabled: "-1", connection_type: "spdisplays_internal", display_id: "1800000", display_type: "", main: "1", manufactured_week: "26", manufactured_year: "2020", mirror: "0", name: "Unknown Display", online: "1", pixels: "1920 x 1080", product_id: "0", resolution: "1920 x 1080 @ 30.00Hz", rotation: "", serial_number: "1", vendor_id: "1006"}
82: 
82: [  FAILED  ] connectedDisplays.test_sanity (527 ms)
82: [----------] 1 test from connectedDisplays (527 ms total)

5f0b8ad updates the docs for the rotation column to reflect the new behavior.

Comment on lines 147 to 150
} else {
r["rotation"] = INTEGER(0);
// rotation is not supported
r["rotation"] = INTEGER(-1);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is arguably a breaking change as rotation used to be 0 for not supported and now it is -1. 🤔 However I don't think these tables (and specifically this column) are widely used as osqueryd crashes if this table is queried while a display is rotated.

Alternatively we could just continue to return 1 for rotation supported and 0 for not supported to avoid breaking the current behavior.

Copy link
Member

Choose a reason for hiding this comment

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

My hunch is that this is fine to change

@Synse
Copy link
Contributor Author

Synse commented Jul 3, 2025

I did some testing with the build from this PR and it's working as intended. 🎉 🚀

Screenshot 2025-07-03 at 12 27 49 PM

@zwass zwass merged commit ad58773 into osquery:master Jul 29, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.