Intermittent FIELD_INTEGRITY_EXCEPTION - Variable does not exist: Contact: Source error on LWC Tooling API deploy

Issue #2067 resolved
Wacław S. created an issue

Hi

Intermittently I’m getting:

Error:(1, 1) FIELD_INTEGRITY_EXCEPTION - Variable does not exist: Contact: Source

when trying to save an LWC that references apex method via Tooling API.

It seems that the issue caused by a Contact.AccountId reference in User object type var in referenced apex class. Apex class itself deploys fine.

I’m saying that it’s intermittent, but in reality it’s more of “works once or twice, then constantly erroring out”. For instance switching API version in component metadata allows to save component once before going back to errors.

CLI: sfdx force:source:deploy works fine each time.

Attaching debug log.

WebStorm 2021.3 + IC2 2.2.1.2

sfdx-cli/7.142.1 win32-x64 node-v16.14.0

Comments (6)

  1. Scott Wells repo owner

    Hi. What you're seeing is another manifestation of this issue:

    https://github.com/msrivastav13/DX-Code-Companion/issues/15

    By default IC2 uses the Tooling API to deploy LWC, and it incorporates several workarounds for the issue linked above so that the much faster Tooling API can be used as often as possible without explicit user intervention. However, it sounds like there's at least one other corner case that is not yet accounted for. The CLI does not use the Tooling API which is why you don't see this issue via the CLI. As a workaround, you can disable LWC deployment via the Tooling API under Illuminated Cloud > Configure Application > Validation and Deployment > Prefer Tooling API for > LWC. However, I'd like to address this specific manifestation so that you can re-enable that feature.

    Unfortunately I'm not seeing the specifics in the provided log. Are you able to isolate the specific usage that causes this issue? So far there are two known problems which can lead to this:

    1. Importing a field from the User object, either directly or indirectly.
    2. Importing an Apex class that uses NavigationMenuItem/NavigationLinkSet/etc.

    Once I am able to reproduce and isolate this, I'll add it to the heuristic used to avoid the linked issue when Tooling API-based LWC deployment is enabled.

  2. Wacław S. reporter

    Thanks @Scott Wells

    Attaching a streamlined lwc + controller bundle that causes this issue. The error message is slightly different, since in my real life setup there are more class layers, but as far as I understand the linked github discussion, it will be the same thing.

  3. Scott Wells repo owner

    Thanks. Easily reproduced and fixed, though if another such corner-case arises, I think I'm just going to have IC2 retry on all FIELD_INTEGRITY_EXCEPTION errors during LWC deployment via the Tooling API. Worst case scenario that would result in a failed deployment via the Metadata API immediately after the same via the Tooling API for a class of legitimate issues, but it address this issue overall. I'd prefer to deal with it tactically, though, so this amendment to the fix/workaround will be included in this week's build (likely Thursday morning). In the interim you can just leave LWC deployment via the Tooling API disabled, then re-enable it once you take the next update.

  4. Log in to comment