Skip to content

fix: correct matching key priority in datapack export queries#451

Open
Codeneos wants to merge 2 commits into
mainfrom
claude/fix-v2-search-datapack-jCUCV
Open

fix: correct matching key priority in datapack export queries#451
Codeneos wants to merge 2 commits into
mainfrom
claude/fix-v2-search-datapack-jCUCV

Conversation

@Codeneos
Copy link
Copy Markdown
Owner

The getQuery method in DatapackExportQueries was incorrectly prioritizing
the Salesforce-queried DRMatchingKey__mdt definition over the statically
configured matchingKey in DatapackTypeDefinitions. This caused OmniScript
and IntegrationProcedure exports to search by Name instead of
Type/SubType/Version/Language, resulting in wrong datapack retrieval and
duplicate records shown without version numbers.

The fix aligns getQuery's priority with the already-correct getMatchingFields
method: exportDefinition.matchingKey takes precedence, falling back to the
Salesforce-queried key, then to the Name field as a last resort.

https://claude.ai/code/session_01XNp87yZic77AnvLuL2gcXg

claude added 2 commits May 14, 2026 17:05
The getQuery method in DatapackExportQueries was incorrectly prioritizing
the Salesforce-queried DRMatchingKey__mdt definition over the statically
configured matchingKey in DatapackTypeDefinitions. This caused OmniScript
and IntegrationProcedure exports to search by Name instead of
Type/SubType/Version/Language, resulting in wrong datapack retrieval and
duplicate records shown without version numbers.

The fix aligns getQuery's priority with the already-correct getMatchingFields
method: exportDefinition.matchingKey takes precedence, falling back to the
Salesforce-queried key, then to the Name field as a last resort.

https://claude.ai/code/session_01XNp87yZic77AnvLuL2gcXg
…itions

A prior refactor changed DatapackDefinitionRegistry.getDatapackTypeDefinitions
to build DatapackTypeDefinition objects from sparse YAML export definitions,
losing the grouping, displayName and matchingKey metadata that was originally
sourced from the static DatapackTypeDefinitions map.

This caused OmniScript and IntegrationProcedure nodes in the explorer to:
- Show all versions as a flat list without Type/SubType grouping
- Display the auto-generated Name field (same for all versions) instead
  of "Version X", making entries look like duplicates
- Omit the version field from the Salesforce query so export could not
  distinguish between versions

The fix adds resolveDatapackTypeDefinition which matches each YAML entry
to the corresponding static definition by datapackType + sobjectType
(namespace-prefix-stripped), falls back to the YAML-derived definition
for any type not present in DatapackTypeDefinitions. The earlier incorrect
change to datapackExportQueries.ts is also reverted; the Salesforce
DRMatchingKey__mdt definitions already carry the correct Type/SubType/Version
fields and should take priority as they allow per-org customisation.

https://claude.ai/code/session_01XNp87yZic77AnvLuL2gcXg
Copilot AI review requested due to automatic review settings May 14, 2026 17:48
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38480453fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

removeNamespacePrefix(def.source.sobjectType) === removeNamespacePrefix(exportDefinition.objectType)
);
if (match) {
return { ...match, exportMode: 'direct' };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve custom export definition queries

When a custom datapack-definitions.yaml reuses a built-in datapack type/object pair, this branch returns the static definition and drops the YAML-derived source built from the custom file. Because loadCustomDefinitionFile() also calls getDatapackTypeDefinitions(), a custom OmniScript/OmniProcess definition with its own filter, limit, name, or matchingKeyFields will be listed in the explorer using the built-in query instead of the user's configured query, so records outside the custom definition can appear or intended records can be omitted. The static fallback should be limited to the bundled definitions or merged without discarding the custom source settings.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

The PR description states the goal is to correct the priority used when selecting a matching key in DatapackExportQueries.getQuery so that exportDefinition.matchingKey is preferred over the Salesforce-derived DRMatchingKey__mdt definition (which was causing OmniScript / IntegrationProcedure exports to match by Name instead of Type/SubType/Version/Language). However, the actual code change is in datapackDefinitionRegistry.ts and adjusts how a DatapackTypeDefinition is resolved from static DatapackTypeDefinitions vs. the YAML-derived export definition; the buggy precedence expression in datapackExportQueries.ts:42 is untouched.

Changes:

  • Extract getDatapackTypeDefinitions's mapping into a new resolveDatapackTypeDefinition helper.
  • When a static DatapackTypeDefinitions entry matches the YAML definition's objectType (with namespace prefix stripped), return that static entry (with exportMode: 'direct') instead of building one from the YAML.
  • Import removeNamespacePrefix from @vlocode/util to perform the namespace-insensitive match.

Comment on lines +143 to 155
private resolveDatapackTypeDefinition(datapackType: string, exportDefinition: DatapackExportDefinition): DatapackTypeDefinition {
const staticEntry = DatapackTypeDefinitions[datapackType];
if (staticEntry) {
const allStatic = Array.isArray(staticEntry) ? staticEntry : [staticEntry];
const match = allStatic.find(def =>
removeNamespacePrefix(def.source.sobjectType) === removeNamespacePrefix(exportDefinition.objectType)
);
if (match) {
return { ...match, exportMode: 'direct' };
}
}
return this.toDatapackTypeDefinition(datapackType, exportDefinition);
}
Comment on lines +150 to +152
if (match) {
return { ...match, exportMode: 'direct' };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants