microg/GmsCore · error · IllegalArgumentException

page exceeds range [0, 255].

Error message

page exceeds range [0, 255].

What it means

ThreadNetworkCredentials.ChannelMaskEntry's constructor validates that the channel `page` fits in an unsigned byte (0-255) and throws IllegalArgumentException otherwise. Channel pages in Thread identify the PHY channel page and are 8-bit values, so any value outside [0,255] is invalid.

Source

Thrown at play-services-threadnetwork/src/main/java/com/google/android/gms/threadnetwork/ThreadNetworkCredentials.java:141

     */
    public long getUpdatedAtMillis() {
        return updatedAtMillis;
    }

    /**
     * The Channel Mask Entry of Thread Operational Dataset.
     */
    public static class ChannelMaskEntry {
        private final int page;
        private final byte[] mask;

        /**
         * Creates a new {@link ChannelMaskEntry} object.
         *
         * @throws IllegalArgumentException if page exceeds range [0, 255].
         */
        public ChannelMaskEntry(int page, byte[] mask) {
            if (page < 0 || page > 255) throw new IllegalArgumentException("page exceeds range [0, 255].");
            this.page = page;
            this.mask = mask;
        }

        /**
         * Returns the Channel Mask.
         */
        public byte[] getMask() {
            return mask;
        }

        /**
         * Returns the Channel Page.
         */
        public int getPage() {
            return page;
        }
    }

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Clamp or validate the page to 0..255 before constructing ChannelMaskEntry
  2. Use page & 0xFF when converting from a wider integer type to normalize
  3. Check whether the value is a channel number that must first be mapped to a page
  4. Reject the input with a clear message before reaching the constructor

Example fix

// before
ChannelMaskEntry entry = new ChannelMaskEntry(page, mask); // throws if page out of range
// after
int normalizedPage = page & 0xFF;
if (normalizedPage != page) throw new IllegalArgumentException("page must be 0-255");
ChannelMaskEntry entry = new ChannelMaskEntry(normalizedPage, mask);
Defensive patterns

Strategy: validation

Validate before calling

if (page < 0 || page > 255) throw new IllegalArgumentException("page must be in [0,255], got " + page);

Type guard

boolean isValidChannelPage(int page) { return page >= 0 && page <= 255; }

Try / catch

try {
    ChannelMaskEntry e = new ChannelMaskEntry(page, mask);
} catch (IllegalArgumentException e) {
    // reject or clamp the page value
}

Prevention

When it happens

Trigger: Constructing a ChannelMaskEntry with page < 0 or page > 255, typically from an unvalidated int parsed from user input or a spec/protocol value that doesn't fit in a byte.

Common situations: Parsing a page value from JSON/config where it was entered as 256+; sign-extension bugs making a byte negative; confusing channel number with channel page.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/1f658f2c53147379. Report an issue: GitHub.