{"record":{"id":"eafb28aad8341c8c","repo":"hasura/graphql-engine","slug":"source-for-the-following-command-is-defined-more-t","errorCode":null,"errorMessage":"source for the following command is defined more than once: {command_name:}","messagePattern":"source for the following command is defined more than once: (.+?)","errorType":"validation","errorClass":"CommandsError::DuplicateCommandSourceDefinition","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/commands/error.rs","lineNumber":79,"sourceCode":"pub enum CommandsError {\n    #[error(\"the following command is defined more than once: {name:}\")]\n    DuplicateCommandDefinition { name: Qualified<CommandName> },\n    #[error(\n        \"the argument '{argument_name}' in command '{command_name}' has an unknown type: {argument_type}\"\n    )]\n    UnknownCommandArgumentType {\n        command_name: Qualified<CommandName>,\n        argument_name: Spanned<ArgumentName>,\n        argument_type: TypeReference,\n    },\n    #[error(\n        \"the following argument in command {command_name:} is defined more than once: {argument_name:}\"\n    )]\n    DuplicateCommandArgumentDefinition {\n        command_name: Qualified<CommandName>,\n        argument_name: Spanned<ArgumentName>,\n    },\n    #[error(\"source for the following command is defined more than once: {command_name:}\")]\n    DuplicateCommandSourceDefinition {\n        command_name: Qualified<CommandName>,\n    },\n    #[error(\n        \"the source data connector {data_connector:} for command {command_name:} has not been defined\"\n    )]\n    UnknownCommandDataConnector {\n        command_name: Qualified<CommandName>,\n        data_connector: Qualified<DataConnectorName>,\n    },\n    #[error(\n        \"the mapping for type {type_name:} in command {command_name:} is defined more than once\"\n    )]\n    DuplicateTypeMappingDefinitionInCommandSource {\n        command_name: Qualified<CommandName>,\n        type_name: CustomTypeName,\n    },\n    #[error(\"command source is required for command '{command_name:}' to resolve argument preset\")]","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/commands/error.rs#L61-L97","documentation":"DuplicateCommandSourceDefinition is raised when a single command has more than one source block defined (e.g. multiple data connector sources or multiple handler entries). A command must have exactly one source of truth; multiple source definitions are ambiguous and rejected by the commands stage.","triggerScenarios":"Declaring a command with both an inline data connector source and another source entry (e.g. two source keys, or a source plus an inherited/merged one from YAML anchors or programmatic metadata merging).","commonSituations":"Metadata templating/merging producing two sources for one command; switching a command from one connector to another and leaving the old source in place; YAML merge keys combining defaults with an explicit source.","solutions":["Inspect the command named in the error and remove the extra source so exactly one remains","If using YAML anchors or programmatic merging, ensure the source key is replaced, not appended","After switching connectors, delete the previous source block from the command"],"exampleFix":"# before\ncommands:\n  - name: getUser\n    source:\n      dataConnector: pg\n    source:            # duplicate\n      dataConnector: mongo\n\n# after\ncommands:\n  - name: getUser\n    source:\n      dataConnector: pg","handlingStrategy":"validation","validationCode":"if let Some(cmd) = metadata.command(&name) {\n    if cmd.sources.len() > 1 {\n        return Err(format!(\"command {name} has {} source definitions; expected exactly 1\", cmd.sources.len()));\n    }\n}","typeGuard":null,"tryCatchPattern":"Match DuplicateCommandSourceDefinition { command_name } and report that the command must keep exactly one source block; include the command's file location if tracked.","preventionTips":["When migrating a command between connectors, replace the source block rather than adding a second one","Avoid YAML anchors that inject a default source into commands that define their own","Assert single-source invariants in programmatic metadata builders"],"tags":["hasura","commands","duplicate","source","metadata"],"backgroundTag":"duplicate-definition","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}