Skip to content

Fix BzlMod exception handling #18629

@katre

Description

@katre

Almost all of the skyfunctions defined for bzlmod support have no exception handling, which means that when an exception does occur, Skyframe drops it and bazel crashes in an inconsistent state.

Issue #18567 is an example of this.

I've done a brief survey of the existing skyfunctions under src/main/java/com/google/devtools/build/lib/bazel/bzlmod/

  • BazelDepGraphFunction
    • key: BazelDepGraphValue.KEY -> singleton instance
    • calls:
      • BazelLockFileValue.KEY
        • no exceptions handled
      • BazelModuleResolutionValue.KEY
        • no exceptions handled
      • ModuleFileValue.key
        • no exceptions handled
      • ClientEnvironmentFunction.key
        • no exceptions handled
    • throws:
      • BazelDepGraphFunctionException
        • ExternalDepsException
  • BazelLockFileFunction
    • key: BazelLockFileValue.KEY -> singleton instance
    • calls:
      • FileValue.key
        • no exceptions handled
    • throws:
      • BazelLockfileFunctionException
        • ExternalDepsException
  • BazelModuleInspectorFunction
    • key: BazelModuleInspectorValue.KEY -> singleton instance
    • calls:
      • ModuleFileValue.KEY_FOR_ROOT_MODULE
      • BazelModuleResolutionValue.KEY
    • throws:
      • nothing
  • BazelModuleResolutionFunction
    • key: BazelModuleResolutionValue.KEY -> singleton instance
    • calls:
      • ClientEnvironmentFunction.key
        • no exceptions handled
      • ModuleFileValue.KEY_FOR_ROOT_MODULE
        • no exceptions handled
    • throws:
      • BazelModuleResolutionFunctionException
        • ExternalDepsException
  • ModuleFileFunction
    • key: ModuleFileValue.Key -> moduleKey, override
    • calls:
      • FileValue.key (twice)
        • no exceptions handled
      • RepositoryDirectoryValue.key
        • no exceptions handled
    • throws:
      • ModuleFileFunctionException
        • ExternalDepsException
  • SingleExtensionEvalFunction
    • key: ModuleExtensionId -> bzlFileLabel, extensionName
    • calls:
      • SingleExtensionUsagesValue.key
        • no exceptions handled
      • BzlLoadValue.keyForBzlmod
        • handles BzlLoadFailedException
    • throws:
      • SingleExtensionEvalFunctionException
        • ExternalDepsException
        • IOException
  • SingleExtensionUsagesFunction
    • key: ModuleExtensionId
    • calls:
      • BazelDepGraphValue.KEY
    • throws:
      • nothing

Every SkyKey can potentially throw the exceptions listed under its Skyfunction (for example, requesting BazelDepGraphValue.KEY can potentially raise ExternalDepsException.

Therefore, each of these functions needs to have existing env.getValue calls converted to env.getValueOrException calls, and then the exception needs to be handled properly, generally by re-throwing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)area-BzlmodBzlmod-specific PRs, issues, and feature requestsstaleIssues or PRs that are stale (no activity for 30 days)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions