iflytek/astron-agent · error · X
INVALID_PARAMETER
INVALID_PARAMETER
Error message
parameter must be numeric type
What it means
This is a custom SDK error (code INVALID_PARAMETER) thrown by the bundled TRTC/XRTC player SDK when setAudioDeviceVolume-like volume APIs are called with a first argument that is >= 0 but is not of primitive type 'number'. The bundled code guards against strings (e.g. '100') or objects being passed where a numeric volume/device id is required, and fails fast with this typed error instead of misbehaving later inside getUserMedia or the audio pipeline.
Solutions
- Convert the argument with Number() before calling the SDK API and check Number.isFinite.
- If the value comes from an input element or JSON config, parse it explicitly (parseFloat/parseInt) rather than passing the raw string.
- Ensure 0 is a valid fallback; if the argument is undefined the SDK defaults to 1000, so only explicitly-passed non-numeric values throw.
- Pin/inspect the avatar SDK bundle (xrtc-player) version if the API signature changed after an upgrade.
Example fix
// before
player.setVolume(formData.volume); // '80' (string from input)
// after
const vol = Number(formData.volume);
if (!Number.isFinite(vol) || vol < 0) throw new Error('volume must be a non-negative number');
player.setVolume(vol); Defensive patterns
Strategy: validation
Validate before calling
function isNumericVolume(v) { return typeof v === 'number' && Number.isFinite(v) && v >= 0; }
if (!isNumericVolume(raw)) throw new TypeError('volume must be a non-negative finite number'); Type guard
const isNum = (v) => typeof v === 'number' && Number.isFinite(v);
Prevention
- Always Number() coerce values coming from DOM inputs, URL params, or JSON config before SDK calls
- Enable runtime validation (zod/valibot) on config objects feeding the SDK
- Never rely on implicit coercion: the SDK uses typeof, not Number(v)
- Add a unit test covering the volume/device API with string input
When it happens
Trigger: Calling an SDK volume/device API whose first parameter must be a number, but passing a non-number that still satisfies the >= 0 precheck path, e.g. a numeric string '80', null, or an object parsed from config. The check 'number' != typeof e throws even for values that would coerce cleanly, so any typeof !== 'number' input triggers it.
Common situations: Developers read a volume setting from an HTML input (value is always a string) or from JSON/localStorage config and pass it straight into the SDK API; TypeScript types are stripped at runtime so a string slips through. Also common when values come from the avatar console backend as strings.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/29178fc6a0732941.
Report an issue: GitHub.
Appendix: source
Thrown at console/frontend/src/utils/avatar-sdk-web_3.1.2.1002/xrtc-player-BJTnVhG9.js:18263
}, e);
})
)),
function () {
return t.apply(this, arguments);
}),
},
{
key: 'enableMicVolume',
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 1e3,
t = arguments.length > 1 ? arguments[1] : void 0,
i = this;
if (e >= 0) {
if ('number' != typeof e)
throw new X({
code: B.INVALID_PARAMETER,
message: 'parameter must be numeric type',
});
navigator.mediaDevices
.getUserMedia({ audio: { deviceId: { exact: t } } })
.then(function (t) {
(i.logger.info('microphone permission is ok'),
(i.micStream = t),
(i.soundMeter = new Q()),
i.soundMeter.connectToSource(
i.micStream.getAudioTracks()[0]
),
(i.timer = setInterval(
function () {
i._emitter.emit('mic-volume', {
volumes: Math.round(100 * i.soundMeter.getVolume()),
});
},View on GitHub (pinned to 5e758547a8)