Skip to content

[Bug] - The action_version attribute of Setup Language classes are not initialized #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tromai opened this issue May 9, 2025 · 0 comments
Labels
bug Something isn't working triage The issue needs to be triaged.

Comments

@tromai
Copy link
Member

tromai commented May 9, 2025

Description

The class instances of type SetupJava, OracleSetupJava and GraalVMSetup do not have the attribute action_version. This is unexpected because action_version is inherited from the base class ThirdPartyAction

Steps to Reproduce

Running on commit e42408a

  1. Set a break point at before this line
    For example
def find_language_setup_action(job_node: GitHubJobNode, lang_name: BuildLanguage) -> Language | None:
    """Find the step that calls a language setup GitHub Actions and return the model.

    Parameters
    ----------
    job_node: GitHubJobNode
        The target GitHub Actions job node.
    lang_name: BuildLanguage
        The target language used in the build.

    Returns
    -------
    Language | None
        The language model for the language setup GitHub Action or None.
    """
    for callee in job_node.callee:
        model = callee.model
        # Check if the model implements the Language protocol.
        if isinstance(model, Language):
            import pdb; pdb.set_trace()
            if model.lang_name == lang_name:
                return model
    return None
  1. Run this command
macaron analyze -purl pkg:maven/org.apache.hugegraph/[email protected]

You will be taken into pdb

> ...//macaron/src/macaron/slsa_analyzer/ci_service/github_actions/analyzer.py(276)find_language_setup_action()
-> if model.lang_name == lang_name:
(Pdb) type(model)
<class 'macaron.slsa_analyzer.ci_service.github_actions.analyzer.SetupJava'>
(Pdb) pp(model)
*** AttributeError: 'SetupJava' object has no attribute 'action_version'
(Pdb) "action_version" in dir(SetupJava)
False

Initial investigation

This happened because of the following factors:

  • SetupJava inherits from ThirdPartyAction, which is a frozen dataclass.
    @dataclass(frozen=True)
    class ThirdPartyAction:
    """The representation for a third-party GitHub Action."""
    #: The name of the GitHub Action.
    action_name: str
    #: The version of the GitHub Action.
    action_version: str | None
  • SetupJava doesn't set the action_version class attribute, instead it just annotate this attribute as None
  • SetupJava defines it owns constructor, which overrides the dataclass constructors generated for ThirdPartyAction. SetupJava constructor doesn't initialize action_version, hence it will never exist in any class instance.
  • This happens for OracleSetupJava and GraalVMSetup with the same reason.

Environment Information

To assist with troubleshooting, please provide the following information about your environment:

Operating System: Ubuntu 22.04

CPU architecture information: x84-64

Bash Version: version 5.1.16(1)-release

Running Macaron as a Python package.

@tromai tromai added bug Something isn't working triage The issue needs to be triaged. labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage The issue needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant