{"record":{"id":"887dc8842a77f6e6","repo":"bevyengine/bevy","slug":"32603","errorCode":"-32603","errorMessage":"Unexpected format of serialized resource value","messagePattern":"Unexpected format of serialized resource value","errorType":"error_code","errorClass":"BrpError","httpStatus":null,"severity":"error","filePath":"crates/bevy_remote/src/builtin_methods.rs","lineNumber":655,"sourceCode":"        return Err(BrpError::resource_not_present(&resource_path));\n    };\n\n    // Use the `ReflectSerializer` to serialize the value of the resource;\n    // this produces a map with a single item.\n    let reflect_serializer = ReflectSerializer::new(reflected.as_partial_reflect(), &type_registry);\n    let Value::Object(serialized_object) =\n        serde_json::to_value(&reflect_serializer).map_err(BrpError::resource_error)?\n    else {\n        return Err(BrpError {\n            code: error_codes::RESOURCE_ERROR,\n            message: format!(\"Resource `{resource_path}` could not be serialized\"),\n            data: None,\n        });\n    };\n\n    // Get the single value out of the map.\n    let value = serialized_object.into_values().next().ok_or_else(|| {\n        BrpError::internal(anyhow!(\"Unexpected format of serialized resource value\"))\n    })?;\n    let response = BrpGetResourcesResponse { value };\n    serde_json::to_value(response).map_err(BrpError::internal)\n}\n\n/// Handles a `world.get_components+watch` request coming from a client.\npub fn process_remote_get_components_watching_request(\n    In(params): In<Option<Value>>,\n    world: &World,\n    mut removal_cursors: Local<HashMap<ComponentId, MessageCursor<RemovedComponentEntity>>>,\n) -> BrpResult<Option<Value>> {\n    let BrpGetComponentsParams {\n        entity,\n        components,\n        strict,\n    } = parse_some(params)?;\n\n    let app_type_registry = world.resource::<AppTypeRegistry>();","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/bevyengine/bevy/blob/78002f65fa984ededb80915b4a5613f195bc864d/crates/bevy_remote/src/builtin_methods.rs#L637-L673","documentation":"BRP's `world.get_resource(s)` handler serializes a resource with ReflectSerializer, which always emits a single-entry JSON map `{type_path: value}`; the handler then extracts that one value. If the map is empty (`into_values().next()` is None), the serializer violated that contract and the server returns an INTERNAL_ERROR (-32603). It signals a broken/custom reflection serialization for that resource type, not a bad request.","triggerScenarios":"A `world.get_resource` / `world.get_resources` BRP request against a resource whose `ReflectSerialize` type data produces an empty serialized object (hand-written reflect Serialize impls, or exotic dynamic types). The request itself is well-formed; serialization output shape is wrong.","commonSituations":"Custom resource types with manually implemented `Serialize`/`ReflectSerialize` that return an empty map; a version mismatch between a BRP client's expectations and the server's Bevy version; extremely rare — most derived `#[derive(Reflect)]` types always produce the single-entry map.","solutions":["Prefer `#[derive(Reflect)]` on the resource instead of a hand-written serialization impl","Test locally: `world.resource::<T>()` serialization via the type registry to reproduce and fix the impl","If the type is a stock Bevy resource and this fires, search Bevy's issue tracker / upgrade — this indicates an engine-side bug","As a client, degrade gracefully: report the resource as unreadable instead of retrying (the result is deterministic)"],"exampleFix":"// before: manual reflect serialize producing an empty map\nimpl ReflectSerialize for MyRes { /* returns map with no entries */ }\n\n// after: derive-based reflection\n#[derive(Resource, Reflect)]\n#[reflect(Resource)]\nstruct MyRes { intensity: f32 }","handlingStrategy":"try-catch","validationCode":"null // no client-side pre-check; probe with world.get_resource for the same type and treat serialization failures as 'unreadable resource'","typeGuard":null,"tryCatchPattern":"// BRP client (JS/TS): fetch or websocket JSON-RPC\nconst res = await brpCall(\"world.get_resource\", { resource: path });\nif (res.error) {\n  if (res.error.code === -32603 && /serialized resource value/i.test(res.error.message)) {\n    console.warn(`Resource ${path} is not remotely serializable; skipping`);\n    continue; // deterministic failure — do not retry\n  }\n  throw res.error;\n}","preventionTips":["Stick to derived #[derive(Reflect)] serialization for resources you plan to read over BRP","Smoke-test remote reads for every custom resource type once at tool startup","Treat -32603 internal errors as engine bugs: collect a repro, don't build retry loops on them"],"tags":["bevy","brp","bevy-remote","reflection","serialization","json-rpc","internal-error"],"backgroundTag":null,"analyzedSha":"78002f65fa984ededb80915b4a5613f195bc864d","analyzedAt":"2026-08-16T09:07:20.800Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}