Compare with server Expericence results not correct structure

Issue #2475 resolved
Oleksandr Tymchenko created an issue

Hi, I have multiple folders inside force-app (main, custom project folders) and when I’m comparing my experience which is not in main folder (from custom project folder), I’m receiving experience results divided by 2.

Comments (7)

  1. Oleksandr Tymchenko reporter
    • force-app

      • projectName

        • experiences

          • cust1
      • main

        • default

          • experiences

            • there is no cust1 experience, but some other project experiences

  2. Scott Wells repo owner

    Hi. Can you please enable debug logging for Metadata Retrieval, reproduce the behavior, and either attach or email the resulting idea*.log* file(s) from the duration of that retrieval? That should show exactly how IC2 is matching retrieved files against local project files. My guess is that there’s just enough intersection in file/path naming in the two that it’s matching some files incorrectly.

  3. Scott Wells repo owner

    Thanks to provided debug logs, I can see why this is happening. The experience bundle in the local project is stored as (source root-relative path) alternativeDir/experiences/RetrievedBundleName/.... The Salesforce CLI retrieves that experience bundle as (temp dir-relative path) force-app/main/default/experiences/RetrievedBundleName/.... Because files with the same name can be found in multiple locations -- specifically under bundle directories -- IC2's retrieved-to-local file matching strategy tries to match using path components leading up to the ambiguous retrieved filename. In this case, the difference between the local alternativeDir/experiences and the retrieved force-app/main/default/experiences combined with the fact that there are also experience bundles stored in the local project under force-app/main/default/experiences results in a matching ambiguity on most of the retrieved experience bundle's files, e.g.:

    2023-12-11 20:43:57,357 [  58457]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever - Processing /path/to/tempDir/tmp/force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json.
    2023-12-11 20:43:57,357 [  58457]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Using filename buildYourOwn.json.
    2023-12-11 20:43:57,358 [  58458]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Found multiple existing files named buildYourOwn.json. Searching for correct match.
    ...
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Comparing 'force-app/main/default/experiences/ExistingBundleName1/brandingSets/buildYourOwn.json' to 'force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json'.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   There are 6/7 = 85,71% matching path components.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   This is the new best match.
    ...
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Comparing 'force-app/main/default/experiences/ExistingBundleName2/brandingSets/buildYourOwn.json' to 'force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json'.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   There are 6/7 = 85,71% matching path components.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   This is the same as the current best match.
    ...
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Comparing 'force-app/main/default/experiences/ExistingBundleName3/brandingSets/buildYourOwn.json' to 'force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json'.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   There are 6/7 = 85,71% matching path components.
    2023-12-11 20:43:57,369 [  58469]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   This is the same as the current best match.
    ...
    2023-12-11 20:43:57,373 [  58473]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Comparing 'force-app/alternativeDir/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json' to 'force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json'.
    2023-12-11 20:43:57,373 [  58473]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   There are 5/7 = 71,43% matching path components.
    ...
    2023-12-11 20:43:57,376 [  58476]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Failed to find an unambiguous best match existing file.
    2023-12-11 20:43:57,376 [  58476]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   No matching existing file found.
    2023-12-11 20:43:57,376 [  58476]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Placing in source root force-app.
    2023-12-11 20:43:57,379 [  58479]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataRetriever -   Moving/copying /path/to/tempDir/tmp/force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json to /path/to/tempDir/diff/force-app/main/default/experiences/RetrievedBundleName/brandingSets as buildYourOwn.json.
    

    As shown above, multiple files named buildYourOwn.json are found under force-app/main/default/experiences locally and result in a "stronger" match against the CLI's retrieved file path of force-app/main/default/experiences/RetrievedBundleName/brandingSets/buildYourOwn.json than the last one shown above which is the correct match. As a result, given that there's no unambiguous "strongest" match, IC2 plays it safe and doesn't risk overwriting any local file, instead using a default source root-relative path.

    While that's the safe behavior and one that has worked well for a good long while, it's obviously not the desired behavior in this specific situation. One way to make this more accurate would be to discern the bundle root directory and use that as the focus when matching, specifically the experiences/RetrievedBundleName portion in this example.

    Before going that route, though, I'm curious as to whether this can be resolved by changing the CLI's package directories and/or the IDE project's source roots to be more specific. Given that the CLI retrieval is happening in a temporary directory, it might not, but let me try to reproduce this behavior locally and then see if it can/should be addressed by using more discrete package directories/source roots instead.

  4. Scott Wells repo owner

    Yeah, it looks like more than a config change is required here. I was able to reproduce incorrect matches/collisions with one experience bundle in the local project by retrieving one or more other experience bundles. I’ll take a look at a proper fix for the next build.

  5. Scott Wells repo owner

    Okay, I’ve implemented a prospective proper fix for this. I’m going to run it through the paces on side, but it would be great if you could also install it via a test build and confirm that it’s producing the correct behavior in your environment as well. That would likely come tomorrow if my current testing bears out well. I’ll let you know when it’s ready either way.

  6. Log in to comment