Skip to content

Change capacity check from fail-open to fail-closed and improve status messages#73

Merged
MrAlders0n merged 5 commits intodevfrom
copilot/fix-fail-open-issue
Dec 20, 2025
Merged

Change capacity check from fail-open to fail-closed and improve status messages#73
MrAlders0n merged 5 commits intodevfrom
copilot/fix-fail-open-issue

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

The capacity check was failing open on network errors, allowing connections to proceed when the API was unreachable or returned errors. This changes the behavior to fail closed - denying connections when capacity cannot be verified. Additionally, status messages have been improved to provide clearer feedback to users.

Changes

content/wardrive.js

  • Modified checkCapacity() to return false (deny) instead of true (allow) when:
    • API returns non-OK HTTP status (e.g., 500, 503)
    • Network exception occurs (unreachable, timeout, etc.)
  • Updated error logging from debugWarn to debugError
  • Separated status messages for better clarity:
    • "WarDriving app has reached capacity" - when API returns allowed=false (capacity is full)
    • "WarDriving app is down" - when network is unreachable or API returns error status
  • Fixed status message stuck on "Acquiring wardriving slot" after successful connection - now shows "Idle"
  • Disconnect operations continue to succeed regardless of capacity check failures

STATUS_MESSAGES.md

  • Documented fail-closed behavior and deprecated fail-open message
  • Split generic error message into two specific messages
  • Updated "Idle" status documentation to include usage after successful connection

Before/After

// Before: Fail-open
catch (error) {
  if (reason === "connect") {
    debugWarn("Failing open (allowing connection) due to network error");
    return true;  // Allow connection
  }
}

// After: Fail-closed  
catch (error) {
  if (reason === "connect") {
    debugError("Failing closed (denying connection) due to network error");
    setStatus("WarDriving app is down", STATUS_COLORS.error);
    return false;  // Deny connection
  }
}

Status Messages:

  • Network/API failures during connect now trigger automatic disconnect after showing specific error status
  • Successful connections now properly transition to "Idle" status instead of remaining stuck on "Acquiring wardriving slot"
Original prompt

The alst PR

Was to implement capcity checking, it seems you implemented a fail open. I always want to fail closed.

If network is down, dont allow the app to continue. If cpacity is full dont allow.

[DEBUG] Failing open (allowing connection) due to network error

See message above^ Always fail closed


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fail open issue in capacity checking Change capacity check from fail-open to fail-closed Dec 20, 2025
Copilot AI requested a review from MrAlders0n December 20, 2025 02:19
@MrAlders0n
Copy link
Collaborator

@copilot Can we seperate those two statues. WarDriving app has reached capacity or is down" SHould be WarDriving app has reached capacity" if the api returns false WarDriving app is down if the api is unreachable

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot Can we seperate those two statues. WarDriving app has reached capacity or is down" SHould be WarDriving app has reached capacity" if the api returns false WarDriving app is down if the api is...

Done in 66ce76f. Status messages are now separated:

  • "WarDriving app has reached capacity" when API returns allowed=false
  • "WarDriving app is down" when network is unreachable or API returns error status

Copilot AI and others added 2 commits December 20, 2025 02:25
…plete

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copilot AI changed the title Change capacity check from fail-open to fail-closed Change capacity check from fail-open to fail-closed and improve status messages Dec 20, 2025
@MrAlders0n MrAlders0n marked this pull request as ready for review December 20, 2025 02:31
@MrAlders0n MrAlders0n merged commit db63bb8 into dev Dec 20, 2025
@MrAlders0n MrAlders0n deleted the copilot/fix-fail-open-issue branch December 20, 2025 05:36
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.

2 participants