Skip to content

fix(validate): accept explicit Integration.load config paths #41

@TheRealAgentK

Description

@TheRealAgentK

Summary

validate_integration.py currently warns when an integration uses an explicit config path with Integration.load(...), for example:

instagram = Integration.load(os.path.join(os.path.dirname(__file__), "config.json"))

The warning says:

Integration should use 'Integration.load()' to load the integration

This is a false positive for multi-file integrations that intentionally pass an explicit config.json path.

Current behavior

In scripts/validate_integration.py, _check_main_python_file() concatenates all Python file contents and checks for the literal substring:

if 'Integration.load()' not in all_content:
    self.add_warning("Integration should use 'Integration.load()' to load the integration")

That means:

  • Integration.load() passes
  • Integration.load("config.json") warns
  • Integration.load(os.path.join(...)) warns
  • a comment or string containing Integration.load() could satisfy the check

INTEGRATION_CHECKLIST.md already documents this limitation as expected for multi-file integrations, but the validator output is still confusing during PR review.

Proposed fix

Update the validator to detect an actual AST call to Integration.load(...), accepting both no-arg and explicit-path forms:

Integration.load()
Integration.load("config.json")
Integration.load(config_path)
Integration.load(os.path.join(os.path.dirname(__file__), "config.json"))

Suggested approach:

  1. Import ast in scripts/validate_integration.py.
  2. Keep collecting Python files as today.
  3. Replace the literal substring check with a helper that parses each file and looks for:
ast.Call(
    func=ast.Attribute(
        value=ast.Name(id="Integration"),
        attr="load",
    )
)
  1. Change the warning text to reference Integration.load(...), not only Integration.load().

Test cases to add

  • Integration.load() should not warn.
  • Integration.load(os.path.join(os.path.dirname(__file__), "config.json")) should not warn.
  • A comment/string containing Integration.load() without an actual call should still warn.

Docs to update

Update:

  • scripts/docs/validate_integration.md
  • INTEGRATION_CHECKLIST.md

The docs should say the validator accepts Integration.load(...) calls, including explicit config-path forms used by multi-file integrations.

Context

This came up while reviewing Autohive-AI/autohive-integrations PR #327 for the Instagram integration SDK v2 upgrade. Instagram is a multi-module integration with an actions/ subfolder and uses an explicit config path to avoid runtime config resolution issues outside pytest's patched Integration.load() behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions