iflytek/astron-agent · error · TypeError

Invalid RID value provided.

Error message

Invalid RID value provided.

What it means

Thrown by the adapter.js addTransceiver polyfill when a sendEncodings entry in the init dict contains a 'rid' value that does not match the spec-mandated pattern ^[a-z0-9]{0,16}$ (case-insensitive). RID (restriction identifier) names must be short alphanumeric strings; anything with hyphens, underscores, symbols, or longer than 16 characters is rejected with a TypeError.

Solutions

  1. Use only 0-16 alphanumeric characters for rid, e.g. 'q', 'h', 'f' or 'low', 'mid', 'high'.
  2. Validate rids against /^[a-z0-9]{0,16}$/i before building sendEncodings.
  3. Sanitize or map externally supplied layer names to compliant rid identifiers.
  4. If rid semantics are not needed, omit rid entirely and let the browser/simulcast defaults apply.

Example fix

// before
addTransceiver(track, { sendEncodings: [{ rid: 'high-quality' }, { rid: 'low_res' }] });

// after
addTransceiver(track, { sendEncodings: [{ rid: 'hq' }, { rid: 'lq' }] });
Defensive patterns

Strategy: validation

Validate before calling

function validEncodings(encs) {
  return encs.every(e => !('rid' in e) || /^[a-z0-9]{0,16}$/i.test(e.rid));
}
// call addTransceiver only if validEncodings(sendEncodings)

Type guard

function hasValidRid(e) {
  return typeof e === 'object' && (!('rid' in e) || (typeof e.rid === 'string' && /^[a-z0-9]{0,16}$/i.test(e.rid)));
}

Try / catch

try {
  pc.addTransceiver(track, { sendEncodings });
} catch (e) {
  if (e instanceof TypeError && /RID/.test(e.message)) {
    // sanitize rids and retry with compliant identifiers
  } else throw e;
}

Prevention

When it happens

Trigger: pc.addTransceiver(track, { sendEncodings: [{ rid: 'high-res' }] }) — a rid containing '-' or '_' or exceeding 16 characters; programmatically generated rids with punctuation; simulcast configs copied from non-standard examples.

Common situations: Configuring simulcast layers with descriptive rid names like 'fhd'/'1080p' (hyphen or digits+letters are fine but '1080-p' is not), templated configs from other SDKs using different rid rules, or user-supplied layer names flowing into sendEncodings.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/e7956cb2b13a0694. Report an issue: GitHub.

Appendix: source

Thrown at console/frontend/src/utils/avatar-sdk-web_3.1.2.1002/xrtc-player-BJTnVhG9.js:19761

        t.track && e.getTracks().includes(t.track) && this.removeTrack(t);
      });
    });
}
function cr(e) {
  e.DataChannel && !e.RTCDataChannel && (e.RTCDataChannel = e.DataChannel);
}
function ur(e) {
  if ('object' != typeof e || !e.RTCPeerConnection) return;
  const t = e.RTCPeerConnection.prototype.addTransceiver;
  t &&
    (e.RTCPeerConnection.prototype.addTransceiver = function () {
      this.setParametersPromises = [];
      const e = arguments[1],
        i = e && 'sendEncodings' in e;
      i &&
        e.sendEncodings.forEach(e => {
          if ('rid' in e && !/^[a-z0-9]{0,16}$/i.test(e.rid))
            throw new TypeError('Invalid RID value provided.');
          if (
            'scaleResolutionDownBy' in e &&
            !(parseFloat(e.scaleResolutionDownBy) >= 1)
          )
            throw new RangeError('scale_resolution_down_by must be >= 1.0');
          if ('maxFramerate' in e && !(parseFloat(e.maxFramerate) >= 0))
            throw new RangeError('max_framerate must be >= 0.0');
        });
      const r = t.apply(this, arguments);
      if (i) {
        const { sender: t } = r,
          i = t.getParameters();
        (!('encodings' in i) ||
          (1 === i.encodings.length &&
            0 === Object.keys(i.encodings[0]).length)) &&
          ((i.encodings = e.sendEncodings),
          (t.sendEncodings = e.sendEncodings),
          this.setParametersPromises.push(

View on GitHub (pinned to 5e758547a8)