Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 29, 2025

This PR addresses the issue where users were seeing unhelpful "Unknown statusCode" messages when the August API returns HTTP 422 errors, making it difficult to diagnose lock control problems.

Problem

Users reported seeing generic error messages like:

[August] [DEBUG] Lock: Garage Door Unknown statusCode: PUT failed with: 422, Submit Bugs Here: https://tinyurl.com/AugustYaleBug

The plugin's status code handling only recognized specific codes (100, 200, 400, 429) but not 422, which is commonly returned by the August API when a lock operation cannot be processed.

Solution

Enhanced Status Code Handling

  • Added specific handling for HTTP 422 (Unprocessable Entity) with a meaningful error message
  • Improved status code extraction using regex pattern \b(\d{3})\b to handle various error message formats like:
    • "PUT failed with: 422"
    • "422"
    • "API call failed: 422"

Defensive API Call Improvements

  • Added double-check validation in pushChanges() to prevent race conditions
  • Enhanced logging to track when API calls are made vs skipped
  • Added defensive checks to ensure states are still different before making API calls

Before/After Comparison

Before:

Unknown statusCode: PUT failed with: 422, Submit Bugs Here: https://tinyurl.com/AugustYaleBug

After:

Unprocessable Entity - The request was well-formed but could not be processed. This may indicate the lock is in an invalid state or the operation is not allowed at this time, statusCode: PUT failed with: 422

Testing

  • Added comprehensive test suite covering all status codes (200, 400, 422, 429, unknown)
  • Tests validate both error message extraction and defensive API call logic
  • All existing tests continue to pass

The changes are minimal and surgical, focusing specifically on improving error messaging while maintaining existing functionality.

Fixes #150.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Support Request: Lock not responding - PUT failed with 422 Fix HTTP 422 error handling and improve status code messaging Aug 29, 2025
@Copilot Copilot AI requested a review from donavanbecker August 29, 2025 13:55
Copilot finished work on behalf of donavanbecker August 29, 2025 13:55
@donavanbecker donavanbecker changed the base branch from latest to beta-3.0.3 August 29, 2025 22:21
@donavanbecker donavanbecker marked this pull request as ready for review August 29, 2025 22:21
@donavanbecker donavanbecker merged commit f0f6ece into beta-3.0.3 Aug 29, 2025
5 checks passed
@donavanbecker donavanbecker deleted the copilot/fix-150 branch August 29, 2025 22:21
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.

Support Request: Lock not responding - PUT failed with 422
2 participants