8000 Project convert emit warning but does the job · Issue #3318 · forcedotcom/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Project convert emit warning but does the job #3318
Open
@Bartheleway

Description

@Bartheleway

Summary

The function in charge of string replacements is parsing file using chunks. When the file is big, it is splitted in several chunk and it might happen that some chunks do not contains the replacement describe in sfdx-project.json thus emitting a warning that we specified a replacement that doesn't exist.

The generated metadata is therefore as expected and no issue with the produced result file, just the command output is wrong.

Steps To Reproduce

  • Setup a sfdx project
  • Configure sfdx-project.json file with
{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "63.0",
    "replacements": [
        {
            "filename": "force-app/main/default/settings/Case.settings-meta.xml",
            "stringToReplace": "#SETTINGS_CASE_EXECUTION_USER#",
            "replaceWithEnv": "ENV_SETTINGS_CASE_EXECUTION_USER"
        },
        {
            "filename": "force-app/main/default/settings/Case.settings-meta.xml",
            "stringToReplace": "#SETTINGS_CASE_EMAIL_ENV#",
            "replaceWithEnv": "ENV_SETTINGS_CASE_EMAIL_ENV",
            "allowUnsetEnvVariable": true
        },
        {
            "filename": "force-app/main/default/settings/Case.settings-meta.xml",
            "stringToReplace": "#SETTINGS_CASE_SYSTEM_EMAIL#",
            "replaceWithEnv": "ENV_SETTINGS_CASE_SYSTEM_EMAIL"
        }
    ]
}
  • In the Case.settings-meta.xml have something like this:
<?xml version="1.0" encoding="UTF-8"?>
<CaseSettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <caseAutoProcUser>false</caseAutoProcUser>
    <caseFeedItemSettings>
        <characterLimit>400</characterLimit>
        <displayFormat>Default</displayFormat>
        <feedItemType>EmailMessageEvent</feedItemType>
    </caseFeedItemSettings>
    <caseFeedReadUnreadLtng>false</caseFeedReadUnreadLtng>
    <caseMergeInLightning>true</caseMergeInLightning>
    <closeCaseThroughStatusChange>true</closeCaseThroughStatusChange>
    <defaultCaseFeedLayoutOn>false</defaultCaseFeedLayoutOn>
    <defaultCaseOwner>#SETTINGS_CASE_EXECUTION_USER#</defaultCaseOwner>
    <defaultCaseOwnerType>User</defaultCaseOwnerType>
    <defaultCaseUser>#SETTINGS_CASE_EXECUTION_USER#</defaultCaseUser>
    <emailActionDefaultsHandlerClass>EmailPublisherLoader</emailActionDefaultsHandlerClass>
    <emailToCase>
        <enableE2CAttachmentAsFile>true</enableE2CAttachmentAsFile>
        <enableE2CDeduplicateAttachments>false</enableE2CDeduplicateAttachments>
        <enableE2CExternalServer>false</enableE2CExternalServer>
        <enableE2CSourceTracking>true</enableE2CSourceTracking>
        <enableEmailToCase>true</enableEmailToCase>
        <enableHtmlEmail>true</enableHtmlEmail>
        <enableNewToReadTriggers>false</enableNewToReadTriggers>
        <enableOnDemandEmailToCase>true</enableOnDemandEmailToCase>
        <enableThreadTokenInBody>true</enableThreadTokenInBody>
        <enableThreadTokenInSubject>false</enableThreadTokenInSubject>
        <movingEmailEnabled>false</movingEmailEnabled>
        <notifyOwnerOnNewCaseEmail>false</notifyOwnerOnNewCaseEmail>
        <overEmailLimitAction>Bounce</overEmailLimitAction>
        <preQuoteSignature>true</preQuoteSignature>
        <replyWithNewContentOnly>false</replyWithNewContentOnly>
        <routingAddresses>
            <addressType>EmailToCase</addressType>
            <caseOrigin>Email</caseOrigin>
            <caseOwner>SOME_QUEUE</caseOwner>
            <caseOwnerType>Queue</caseOwnerType>
            <casePriority>Medium</casePriority>
            <createTask>false</createTask>
            <emailAddress>someemail#SETTINGS_CASE_EMAIL_ENV#@somedomain.com</emailAddress>
            <isPermsetControlled>false</isPermsetControlled>
            <routingName>Email1</routingName>
            <saveEmailHeaders>true</saveEmailHeaders>
        </routingAddresses>
        <routingAddresses>
            <addressType>EmailToCase</addressType>
            <caseOrigin>Email</caseOrigin>
            <caseOwner>SOME_QUEUE</caseOwner>
            <caseOwnerType>Queue</caseOwnerType>
            <casePriority>Medium</casePriority>
            <createTask>false</createTask>
            <emailAddress>someemail1#SETTINGS_CASE_EMAIL_ENV#@somedomain.com</emailAddress>
            <isPermsetControlled>false</isPermsetControlled>
            <routingName>Email2</routingName>
            <saveEmailHeaders>true</saveEmailHeaders>
        </routingAddresses>
        <showServiceEmailOpenPrompt>false</showServiceEmailOpenPrompt>
        <showWordCountInComposer>false</showWordCountInComposer>
        <unauthorizedSenderAction>Bounce</unauthorizedSenderAction>
        <useEmailHeadersForThreading>true</useEmailHeadersForThreading>
    </emailToCase>
    <enableCaseFeed>true</enableCaseFeed>
    <enableCaseSwarming>false</enableCaseSwarming>
    <enableCollapseEmailThread>true</enableCollapseEmailThread>
    <enableDraftEmails>true</enableDraftEmails>
    <enableEarlyEscalationRuleTriggers>false</enableEarlyEscalationRuleTriggers>
    <enableEmailActionDefaultsHandler>true</enableEmailActionDefaultsHandler>
    <enableEscalateQfiToCaseInternal>false</enableEscalateQfiToCaseInternal>
    <enableEscalateQfiToCaseNetworks>false</enableEscalateQfiToCaseNetworks>
    <enableMultiLangSolnSrchCSS>false</enableMultiLangSolnSrchCSS>
    <enableMultiLangSolnSrchPKB>false</enableMultiLangSolnSrchPKB>
    <enableMultiLangSolution>false</enableMultiLangSolution>
    <enableSolutionCategory>false</enableSolutionCategory>
    <enableSolutionInlineCategory>true</enableSolutionInlineCategory>
    <enableSolutionShortSummary>true</enableSolutionShortSummary>
    <enableSuggestedSolutions>true</enableSuggestedSolutions>
    <escalateCaseBefore>false</escalateCaseBefore>
    <keepCaseMergeRecords>true</keepCaseMergeRecords>
    <keepRecordTypeOnAssignmentRule>true</keepRecordTypeOnAssignmentRule>
    <notifyContactOnCaseComment>false</notifyContactOnCaseComment>
    <notifyDefaultCaseOwner>false</notifyDefaultCaseOwner>
    <notifyOwnerOnCaseComment>false</notifyOwnerOnCaseComment>
    <notifyOwnerOnCaseOwnerChange>false</notifyOwnerOnCaseOwnerChange>
    <rtaCaseComment>false</rtaCaseComment>
    <showEmailAttachmentsInCaseAttachmentsRL>false</showEmailAttachmentsInCaseAttachmentsRL>
    <showFewerCloseActions>false</showFewerCloseActions>
    <systemUserEmail>#SETTINGS_CASE_SYSTEM_EMAIL#</systemUserEmail>
    <useSystemEmailAddress>true</useSystemEmailAddress>
    <useSystemUserAsDefaultCaseUser>false</useSystemUserAsDefaultCaseUser>
    <visibleInCssCheckbox>false</visibleInCssCheckbox>
    <webToCase>
        <enableWebToCase>false</enableWebToCase>
    </webToCase>
</CaseSettings>
  • Run sf project convert source -p force-app/main/default/settings/Case.settings-meta.xml --json -d ./generated with (powershell version):
    • $env:SF_APPLY_REPLACEMENTS_ON_CONVERT="true"
    • $env:ENV_SETTINGS_CASE_SYSTEM_EMAIL="test@test.com"
    • $env:ENV_SETTINGS_CASE_EXECUTION_USER="test"

Expected result

Success without warning

{
  "status": 0,
  "result": {
    "location": "[PROJECT_DIR]\\generated"
  },
  "warnings": []
}

Actual result

Success with warning:

{
  "status": 0,
  "result": {
    "location": "[PROJECT_DIR]\\generated"
  },
  "warnings": [
    "Your sfdx-project.json specifies that /#SETTINGS_CASE_SYSTEM_EMAIL#/g should be replaced in [PROJECT_DIR]\\force-app\\main\\default\\settings\\Case.settings-meta.xml, but it was not found.",
    "Your sfdx-project.json specifies that /#SETTINGS_CASE_EXECUTION_USER#/g should be replaced in [PROJECT_DIR]\\force-app\\main\\default\\settings\\Case.settings-meta.xml, but it was not found."
  ]
}

Additional information

The given XML file will not fail as it is too small, you need to duplicate the routingAddresses node several time to get the warning. In our case we have 120 node.

Warning is emitted by https://github.com/forcedotcom/source-deploy-retrieve/blob/69064f517dea01a0695312c02a53f7498b362137/src/convert/replacements.ts#L84
because https://github.com/forcedotcom/source-deploy-retrieve/blob/69064f517dea01a0695312c02a53f7498b362137/src/convert/replacements.ts#L74 is false in the chunk.

System Information

powershell vs code terminal & custom docker runner (using debian-slim) on gitlab

{
  "cliVersion": "@salesforce/cli/2.92.7",
  "architecture": "win32-x64",
  "nodeVersion": "node-v22.13.1",
  "osVersion": "Windows_NT 10.0.22631",
  "shell": "cmd.exe",
  "rootPath": "C:\\Users\\[someUsername]\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.29 (core)",
    "@oclif/plugin-commands 4.1.25 (core)",
    "@oclif/plugin-help 6.2.28 (core)",
    "@oclif/plugin-not-found 3.2.55 (core)",
    "@oclif/plugin-plugins 5.4.39 (core)",
    "@oclif/plugin-search 1.2.24 (core)",
    "@oclif/plugin-update 4.6.42 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.40 (core)",
    "@oclif/plugin-which 3.2.35 (core)",
    "@salesforce/cli 2.92.7 (core)",
    "agent 1.22.8 (core)",
    "apex 3.6.19 (core)",
    "api 1.3.3 (core)",
    "auth 3.6.126 (core)",
    "data 4.0.37 (core)",
    "deploy-retrieve 3.22.19 (core)",
    "info 3.4.65 (core)",
    "limits 3.3.56 (core)",
    "marketplace 1.3.8 (core)",
    "org 5.7.13 (core)",
    "packaging 2.14.0 (core)",
    "schema 3.3.65 (core)",
    "settings 2.4.29 (core)",
    "sobject 1.4.59 (core)",
    "telemetry 3.6.43 (core)",
    "templates 56.3.49 (core)",
    "trust 3.7.97 (core)",
    "user 3.6.25 (core)",
    "sfdx-cli-enhanced 0.0.1 (link) C:\\altdev430\\vs_workspace\\sfdx-cli-enhanced"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bugvalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0