Skip to content

Conversation

@madhavilosetty-intel
Copy link
Contributor

…ed off

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • All commented code has been removed
  • If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.

What are you changing?

Anything the reviewer should know when reviewing this PR?

If the there are associated PRs in other repositories, please link them here (i.e. device-management-toolkit/repo#365 )

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the power state endpoint to return a default value of 0 for OSPowerSavingState when the device is powered off or the value cannot be retrieved. The changes include refactoring code formatting across multiple files to improve readability by splitting long function calls across multiple lines.

Key changes:

  • Modified getPowerState.ts to handle null/missing OSPowerSavingState values by defaulting to 0
  • Added comprehensive test coverage for various error scenarios in OSPowerSavingState retrieval
  • Reformatted long function calls across multiple files for better readability

Reviewed changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/routes/amt/getPowerState.ts Fixed bug by returning default value of 0 for OSPowerSavingState when unavailable and simplified conditional logic
src/routes/amt/getPowerState.test.ts Added four new test cases covering error scenarios, null responses, missing fields, and timeouts for OSPowerSavingState
src/utils/wsRedirect.test.ts Reformatted long test assertions to multi-line format for improved readability
src/routes/devices/index.ts Reformatted route definition to multi-line format
src/routes/amt/index.ts Reformatted route definition to multi-line format
src/routes/amt/certificates/delete.ts Reformatted find() predicate to multi-line format
src/routes/amt/certificates/delete.test.ts Reformatted long test assertions to multi-line format
src/index.ts Reformatted import statement and logger.warn call to multi-line format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@madhavilosetty-intel madhavilosetty-intel enabled auto-merge (squash) January 5, 2026 21:07
@graikhel-intel graikhel-intel linked an issue Jan 5, 2026 that may be closed by this pull request
2 tasks
Copy link
Contributor

@graikhel-intel graikhel-intel left a comment

Choose a reason for hiding this comment

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

LGTM!

@madhavilosetty-intel madhavilosetty-intel merged commit f7a0adf into main Jan 5, 2026
7 checks passed
@madhavilosetty-intel madhavilosetty-intel deleted the OSPowerSavingState branch January 5, 2026 21:13
RosieAMT pushed a commit that referenced this pull request Jan 5, 2026
## [2.25.3](v2.25.2...v2.25.3) (2026-01-05)

### Bug Fixes

* Return default value for OSPowerSavingState when device is powered off ([#2277](#2277)) ([f7a0adf](f7a0adf))
@RosieAMT
Copy link

RosieAMT commented Jan 5, 2026

🎉 This PR is included in version 2.25.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get Power State API returns 400 when device is powered off

3 participants