{"record":{"id":"12e6d44a4017bfe8","repo":"diem/diem","slug":"expected-to-parse-struct-tag-but-got","errorCode":null,"errorMessage":"Expected to parse struct tag, but got {}","messagePattern":"Expected to parse struct tag, but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs","lineNumber":303,"sourceCode":"\n    /// Returns a deserialized representation of the resource value stored at `resource_path`.\n    /// Returns Err if the path does not hold a resource value or the resource cannot be deserialized\n    pub fn view_resource(&self, resource_path: &Path) -> Result<Option<AnnotatedMoveStruct>> {\n        if resource_path.is_dir() {\n            bail!(\n                \"Bad resource path {:?}. Needed file, found directory\",\n                resource_path\n            )\n        }\n        match resource_path.file_stem() {\n            None => bail!(\n                \"Bad resource path {:?}; last component must be a file\",\n                resource_path\n            ),\n            Some(name) => Ok({\n                let id = match parser::parse_type_tag(&name.to_string_lossy())? {\n                    TypeTag::Struct(s) => s,\n                    t => bail!(\"Expected to parse struct tag, but got {}\", t),\n                };\n                match Self::get_bytes(resource_path)? {\n                    Some(resource_data) => {\n                        Some(MoveValueAnnotator::new(self).view_resource(&id, &resource_data)?)\n                    }\n                    None => None,\n                }\n            }),\n        }\n    }\n\n    fn get_events(&self, events_path: &Path) -> Result<Vec<Event>> {\n        Ok(if events_path.exists() {\n            match Self::get_bytes(events_path)? {\n                Some(events_data) => bcs::from_bytes::<Vec<Event>>(&events_data)?,\n                None => vec![],\n            }\n        } else {","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs#L285-L321","documentation":"After reading the file stem, view_resource parses it as a Move TypeTag and requires it to be a struct (TypeTag::Struct). A parsable but non-struct tag — e.g. a primitive like 'u64' or a vector — cannot identify a resource, so the error reports the actual parsed tag.","triggerScenarios":"The resource file's name parses as a valid type tag but is not a struct: files named like 'u64.bcs', 'vector<u8>.bcs', 'address.bcs', or a signer type instead of a struct type such as 0x1::coin::CoinStore<...>.","commonSituations":"Renaming resource files manually; copy scripts that mangle struct tags; pointing view at bytecode or non-resource files whose names happen to be type tags.","solutions":["Rename/point to a file whose stem is a full struct type tag: <address>::<module>::<Struct><type args>.","Verify the path targets a file produced by the sandbox resource dump, not an arbitrary file.","Check the tag for dropped generic arguments or module path segments that change parsing."],"exampleFix":"// before\nmove view --resource-path ./state/0x42/resources/u64.bcs\n// after\nmove view --resource-path ./state/0x42/resources/0x1::coin::CoinStore<0x42>.bcs","handlingStrategy":"validation","validationCode":"use move_core_types::language_storage::TypeTag;\nuse move_core_types::parser;\nfn parse_struct_tag_name(name: &str) -> Option<String> {\n    match parser::parse_type_tag(name) {\n        Ok(TypeTag::Struct(_)) => Some(name.to_string()),\n        _ => None,\n    }\n}","typeGuard":"fn is_struct_tag(s: &str) -> bool {\n    matches!(move_core_types::parser::parse_type_tag(s), Ok(move_core_types::language_storage::TypeTag::Struct(_)))\n}","tryCatchPattern":"match parser::parse_type_tag(name) {\n    Ok(TypeTag::Struct(s)) => view(s),\n    Ok(other) => eprintln!(\"{} is not a struct tag\", other),\n    Err(e) => eprintln!(\"unparseable tag: {}\", e),\n}","preventionTips":["Name resource files with full struct tags (addr::module::Name<...>), never primitive type names.","Validate the stem parses as a struct TypeTag before calling view_resource.","Only point view at files produced by the sandbox resource dump."],"tags":["move-cli","parsing","type-tag","resources"],"backgroundTag":"expected-struct-tag","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}