{"record":{"id":"30a6d947f66d0764","repo":"diem/diem","slug":"invalid-module-access-did-not-expect-type-argumen","errorCode":null,"errorMessage":"Invalid module access. Did not expect type arguments","messagePattern":"Invalid module access\\. Did not expect type arguments","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"language/testing-infra/transactional-test-runner/src/tasks.rs","lineNumber":329,"sourceCode":"        }\n    }\n}\n\n#[derive(Debug, StructOpt)]\npub struct EmptyCommand {}\n\nfn parse_account_address(s: &str) -> Result<AccountAddress> {\n    let n = move_lang::shared::parse_u128(s)\n        .map_err(|e| anyhow!(\"Failed to parse address. Got error: {}\", e))?;\n    Ok(AccountAddress::new(n.to_be_bytes()))\n}\n\nfn parse_qualified_module_access(s: &str) -> Result<(ModuleId, Identifier)> {\n    match move_core_types::parser::parse_type_tag(s)? {\n        TypeTag::Struct(s) => {\n            let id = ModuleId::new(s.address, s.module);\n            if !s.type_params.is_empty() {\n                bail!(\"Invalid module access. Did not expect type arguments\")\n            }\n            Ok((id, s.name))\n        }\n        _ => bail!(\"Invalid module access\"),\n    }\n}\n\nfn parse_qualified_module_access_with_type_args(\n    s: &str,\n) -> Result<(ModuleId, Identifier, Vec<TypeTag>)> {\n    match move_core_types::parser::parse_type_tag(s)? {\n        TypeTag::Struct(s) => {\n            let id = ModuleId::new(s.address, s.module);\n            Ok((id, s.name, s.type_params))\n        }\n        _ => bail!(\"Invalid module access\"),\n    }\n}","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/language/testing-infra/transactional-test-runner/src/tasks.rs#L311-L347","documentation":"parse_qualified_module_access parses a string like '0x1::coin::Coin' into (ModuleId, Identifier) via parse_type_tag. A struct TypeTag with generic type parameters (e.g. '0x2::coin::Coin<0x1::sui::SUI>') is rejected because module access in test directives must reference a plain module member without generics. Non-struct type tags are rejected with the sibling 'Invalid module access' error.","triggerScenarios":"Passing a qualified name with type arguments such as '0x2::coin::Coin<u64>' to a directive that expects parse_qualified_module_access; also any non-struct type tag (primitives, vectors) hits the generic 'Invalid module access' branch instead.","commonSituations":"Copy-pasting a generic struct type (with <...>) where a module/function path is required, e.g. in resource-query or publish-related test directives.","solutions":["Remove the <...> type arguments and pass only the module/member path, e.g. 0x2::coin::Coin","If generics are needed, check whether the directive or harness supports type args elsewhere; this parser does not","Ensure the string parses as a struct type tag: address::module::name form"],"exampleFix":"// before\n//# resource-query 0x2::coin::Coin<0x1::sui::SUI>\n// after\n//# resource-query 0x2::coin::Coin","handlingStrategy":"validation","validationCode":"fn has_no_type_args(s: &str) -> bool {\n    let t = move_core_types::parser::parse_type_tag(s).ok();\n    matches!(t, Some(TypeTag::Struct(st)) if st.type_params.is_empty())\n}","typeGuard":"fn plain_module_access(s: &str) -> Option<(ModuleId, Identifier)> {\n    match move_core_types::parser::parse_type_tag(s).ok()? {\n        TypeTag::Struct(st) if st.type_params.is_empty() =>\n            Some((ModuleId::new(st.address, st.module), st.name)),\n        _ => None,\n    }\n}","tryCatchPattern":"match parse_qualified_module_access(arg) {\n    Err(e) if e.to_string().contains(\"Did not expect type arguments\") => {\n        bail!(\"strip <...> generics from module path: {}\", arg)\n    }\n    other => other,\n}","preventionTips":["Never include <...> type arguments in directives resolved by parse_qualified_module_access","Use plain address::module::member form for resource queries","Distinguish struct type usage (generics allowed) from module access (generics forbidden) in test files"],"tags":["move","testing","module","parse"],"backgroundTag":"unexpected-argument-type","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"}