The App That Kept Registering Itself

Medium

· Backend

Incident

SEV-1

BUG-E911-TEAMS

Priority: Critical (emergency calling) · reported by carrier escalation

Time to fix: 20 min

Failing checks on the shipped build

  • re-registering on every launch keeps one entry

    one SIM + one Teams account: expected 2 but got 21

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Microsoft Teams · 2022

Modelled on the Microsoft Teams / Android emergency-call issue of January 2022. Google and Microsoft reported that on some Android phones with the Teams app installed but not signed in, certain 911 calls could fail. Teams was repeatedly registering calling accounts with the Android platform, and the way the platform then chose between registered accounts could leave an emergency call without the right one. Microsoft shipped a Teams update and Google an Android platform fix.

This project is a simplified reconstruction: PhoneAccountRegistry records every registration, and the locked EmergencyRouter only ranks the most recently registered accounts, so a flood of duplicates pushes the SIM out of consideration.

Make registration idempotent.

Code map

class PhoneAccountRegistry {
    final List<PhoneAccount> accounts = new ArrayList<>();

    // Called by apps whenever they (re)initialise their calling integration.
    void register(String app, String handle, boolean simBacked) {
        accounts.add(new PhoneAccount(app, handle, simBacked));
    }

    int size() {
        return accounts.size();
    }

    PhoneAccount emergencyAccount() {
        return EmergencyRouter.pick(accounts);
    }
}

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The App That Kept Registering Itself — Java Bug Hunt

Modelled on the Microsoft Teams / Android emergency-call issue of January 2022.

  • Language: Java
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Idempotency, State
  • Modelled on: Microsoft Teams · 2022
  • Visible tests: the SIM handles emergency calls on a fresh registry; re-registering on every launch keeps one entry
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (emergency calling))
  • Ticket: BUG-E911-TEAMS
  • Reported by: carrier escalation
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • re-registering on every launch keeps one entry — one SIM + one Teams account: expected 2 but got 21

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Modelled on the Microsoft Teams / Android emergency-call issue of January 2022. Google and Microsoft reported that on some Android phones with the Teams app installed but not signed in, certain 911 calls could fail. Teams was repeatedly registering calling accounts with the Android platform, and the way the platform then chose between registered accounts could leave an emergency call without the right one. Microsoft shipped a Teams update and Google an Android platform fix.

This project is a simplified reconstruction: PhoneAccountRegistry records every registration, and the locked EmergencyRouter only ranks the most recently registered accounts, so a flood of duplicates pushes the SIM out of consideration.

Make registration idempotent.

Bug report

BUG-E911-TEAMS · Priority: Critical (emergency calling) · Reported by: carrier escalation

PhoneAccountRegistry.register(app, handle, simBacked):

  • the registry holds at most ONE account per (app, handle) pair
  • registering a pair that is already present updates that entry's simBacked flag in place — its position in the list does not change
  • a new pair is appended at the end
  • different handles from the same app are different accounts

emergencyAccount() must keep returning the SIM account however many times an app re-registers itself.

Observed: an app that re-registers on every launch while signed out fills the registry, and emergencyAccount() returns null.

Logs

[telecom] registerPhoneAccount com.microsoft.teams/teams (count=19)
[telecom] registerPhoneAccount com.microsoft.teams/teams (count=20)
[telecom] emergency call: no SIM-backed account in ranking window

The code as shipped

src/telecom/PhoneAccountRegistry.java (editable)

class PhoneAccountRegistry {
    final List<PhoneAccount> accounts = new ArrayList<>();

    // Called by apps whenever they (re)initialise their calling integration.
    void register(String app, String handle, boolean simBacked) {
        accounts.add(new PhoneAccount(app, handle, simBacked));
    }

    int size() {
        return accounts.size();
    }

    PhoneAccount emergencyAccount() {
        return EmergencyRouter.pick(accounts);
    }
}

Read-only context: src/telecom/PhoneAccount.java.

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Java bug hunts.