Skip to content

iris.cls("Pkg.X").Method() ignores the class-name string, producing false and mis-targeted CALLS edges #1260

Closed

Description

@isc-tdyar

Summary

In Python code that talks to InterSystems IRIS, iris.cls("Pkg.X").Method() is
the standard way to invoke an ObjectScript class method. CBM creates a CALLS
edge for these but resolves the target by bare method name only, discarding the
class-name string literal.

Consequences:

  • calls resolve to the wrong class when two classes share a method name
  • calls to a class that does not exist in the graph still produce an edge
  • unrelated receivers (anything.Run(...)) produce an edge to whichever class
    happens to define Run

db.classMethodValue("Pkg.X", "Method", ...), the lower-level form this API is
meant to replace, resolves correctly and class-aware. So the form the ecosystem
is being encouraged to adopt is the one handled worst.

Reproduction

Repo with two ObjectScript classes, Pkg.A and Pkg.B, each defining only:

ClassMethod Run(x As %String) As %String
{
    Quit x
}

and one caller.py:

import iris

def want_a():
    return iris.cls("Pkg.A").Run("x")

def want_b():
    return iris.cls("Pkg.B").Run("x")

def want_nonexistent():
    return iris.cls("Pkg.DoesNotExist").Run("x")

def unrelated_receiver():
    return some_random_thing.Run("x")

def via_classmethodvalue(db):
    return db.classMethodValue("Pkg.B", "Run", "x")

Query:

MATCH (a)-[r:CALLS]->(b) RETURN a.name, b.qualified_name

Observed:

  unrelated_receiver     Pkg.A.Run     <-- false edge
  via_classmethodvalue   Pkg.B.Run     <-- correct (class-aware path)
  want_a                 Pkg.A.Run     <-- correct, but only coincidentally
  want_b                 Pkg.A.Run     <-- WRONG CLASS
  want_nonexistent       Pkg.A.Run     <-- false edge

Four of the five iris.cls and bare-receiver edges are wrong. The one correct
row is the classMethodValue form.

Root cause

iris.cls(...) is not recognized as a dispatch receiver, so the call falls
through to generic bare-method-name matching. The class string sits right there
as a literal argument at the call site and is never consulted.

The machinery already exists for the sibling API.
internal/cbm/extract_calls.c:65 defines s_py_dispatch_suffixes for
classMethodValue / classMethodVoid / classMethodBoolean /
classMethodObject, resolved class-aware at :2301-2318.

Suggested fix

  1. When a call's receiver is itself a call to iris.cls / cls with a
    string-literal first argument, synthesize the callee qualified name as
    "<class-literal>.<method>" and resolve it the way classMethodValue
    already is.
  2. Suppress the generic bare-name fallback for that call node, so an
    unresolvable class yields no edge rather than a wrong one.
  3. Separately, invokeClassMethod is missing from s_py_dispatch_suffixes
    (extract_calls.c:65-66) though it is documented alongside the
    classMethod* family. One-line addition, same resolution path.

Item 2 matters most. A missing edge is recoverable; a confidently wrong edge is
not.

Scope note

This sits entirely within CBM's own extraction code, no vendored files
involved. It is independent of Issues A and C and can land on its own.

Tests

I'd add cases to the existing Python call-extraction group in
tests/test_extraction.c covering correct class selection with two same-named
methods, no edge for an unknown class literal, no edge for a non-iris.cls
receiver, and invokeClassMethod resolution.

Happy to open a PR once you confirm the approach, particularly the
"suppress the bare-name fallback" decision, since it makes CBM emit strictly
fewer edges here and I want to be sure that's the behavior you want.

Activity

  1. added
    bugSomething isn't working
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Jul 28, 2026
  2. added this to the 0.9.1-rc milestone on Jul 28, 2026
  3. DeusData commented on Jul 28, 2026

    @DeusData
    Owner

    Thanks for the class-aware minimal case and for calling out the false-edge outcome as worse than a missing edge.

    Current main's Python string-dispatch allowlist contains classMethodValue/classMethodVoid/classMethodBoolean/classMethodObject (internal/cbm/extract_calls.c:63-76) and synthesizes class.method from the first two string arguments (extract_calls.c:2301-2318). There is no iris.cls receiver path, so those calls remain eligible for the generic bare-name resolver. That confirms the reported asymmetry.

    I have routed this to 0.9.1-rc at priority/high. This response confirms the bug, not a particular implementation design; suppressing confidently wrong fallback edges is the required correctness boundary. Thank you.

  4. DeusData commented on Sep 26, 2026

    @DeusData
    Owner

    Thank you, @isc-tdyar, for the class-aware minimal case, and for pointing out that a false edge is worse than a missing one!

    On current main the false edges are gone: want_nonexistent and unrelated_receiver no longer produce CALLS. Cross-language suffix matches were dropped (416ba99), and weak Python member calls are now suppressed (b6a2284). classMethodValue still resolves by class to Pkg.B.Run.

    A milder asymmetry remains: iris.cls("Pkg.A").Run() now gets no edge at all, because there is still no iris.cls receiver path next to the classMethod* dispatch in extract_calls.c. Your suggested fix slots straight into the existing string-dispatch code: when the receiver is iris.cls("<literal>"), build <class-literal>.<method>. Since you know this area best, would you like to open a small PR with your repro as the test? If you'd rather not, we'll pick it up.

  5. isc-tdyar commented on Sep 26, 2026

    @isc-tdyar
    ContributorAuthor

    Yes, I'll take it. Thanks for re-checking on current main. Good to know the
    false edges are already gone.

    Plan: add an iris.cls("<literal>") receiver path next to the classMethod*
    string dispatch in extract_calls.c that builds <class-literal>.<method>.
    If the argument isn't a string literal, the call keeps its current behavior,
    so nothing new gets guessed. The test is the original repro. The two-classes
    case must resolve iris.cls("Pkg.A").Run() to Pkg.A.Run, and the
    nonexistent-class and unrelated-receiver cases must still produce no edge.

    One related gap I noted in the original report: invokeClassMethod is still
    missing from s_py_dispatch_suffixes. It takes the same (class, method)
    string arguments as classMethodValue, so it's a one-line addition. I'd fold
    it into the same PR with its own test unless you'd rather keep it separate.

  6. DeusData commented on Sep 27, 2026

    @DeusData
    Owner

    Fixed on main in 64cf275 (PR #2367, thanks to @isc-tdyar): iris.cls("Pkg.X").Method() now resolves to the named class. Thank you for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions