Skip to content

A stopped install routine that only reads Company makes every table unknown: its reach adds all Company table-event subscribers, so the login's reads refuse every test #8238

Description

@SShadowS

When an install routine stops, every test is refused if the routine declares a Record Company, even one it only reads. The reach of the stopped routine then holds every table, so anything the test session's login reads hits the watch that 98b9c5a added (company open is watched for the rows of stopped install code):

the code that runs when the test session opens the company (Company Triggers subscribers, the login) it read or wrote table API Webhook Subscription, whose rows install code that did not run to its end leaves unknown: install routine codeunit "PX Install".OnInstallAppPerCompany could not run: an outbound HTTP request that a test handler does not answer ...

runtime::subscribers_reached_from (crates/al-testrun/src/runtime/blocked.rs:167-179) adds the subscribers of every event of every table the routine declares a record of. A routine that only calls Company.IsEmpty() therefore reaches Base App's OnBeforeDeleteEvent and OnAfterDeleteEvent subscribers on Company (CDSIntTableSubscriber.DeleteCouplingOnBeforeDeleteCompany, OnboardingSignal.OnAfterDeleteCompany). One of them writes through a RecordRef whose table is not known, so RecRefWrites::any_table is set and install::touched (install.rs:1945) returns every table. The login then reads API Webhook Subscription (the global trigger setup does on the first write to any table), or any other table, and the codeunit is refused.

Table events fire only on writes to that table: IsEmpty, Get, Find and Count raise no table event. A routine that never writes Company sets off no Company table subscriber in BC.

Install code that counts or picks companies is common (Company.Count() > 1, a FindFirst before a Copy Company). This stops whole suites.

Checked on 380f879 (3.0.0-alpha.14). The same suites passed on c43e4ed.

Repro

app.json: platform and application 29.0.0.0, runtime 17.0, ids 50300-50349.

table 50300 "PX Install Row"
{
    fields { field(1; Code; Code[20]) { } }
    keys { key(PK; Code) { Clustered = true; } }
}

table 50301 "PX Open Row"
{
    fields { field(1; Code; Code[20]) { } }
    keys { key(PK; Code) { Clustered = true; } }
}

codeunit 50300 "PX Install"
{
    Subtype = Install;

    trigger OnInstallAppPerCompany()
    var
        Row: Record "PX Install Row";
        Client: HttpClient;
        Response: HttpResponseMessage;
    begin
        Row.Code := 'A';
        Row.Insert();
        Client.Get('https://example.com/config', Response);
        CountCompanies();
    end;

    local procedure CountCompanies()
    var
        Company: Record Company;
    begin
        if Company.IsEmpty() then
            exit;
    end;
}

codeunit 50301 "PX Company Open"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"System Initialization", OnAfterLogin, '', false, false)]
    local procedure OnAfterLogin()
    var
        Row: Record "PX Open Row";
    begin
        if Row.Get('B') then;
    end;
}

codeunit 50302 "PX Test"
{
    Subtype = Test;

    [Test]
    procedure ReadsTheLoginRowOnly()
    var
        Row: Record "PX Open Row";
    begin
        if Row.Get('B') then;
    end;

    [Test]
    procedure ReadsTheInstallRow()
    var
        Row: Record "PX Install Row";
    begin
        Row.Get('A');
    end;
}
al-runner test --verbose --bc-version 29 --environment onprem --companies "CRONUS International Ltd." --test-data=<Sandbox 29.1 base .bak> webhookwatch
NOT RUN 50302 PX Test.ReadsTheLoginRowOnly: the code that runs when the test session opens the company (Company Triggers subscribers, the login) it read or wrote table PX Open Row, whose rows install code that did not run to its end leaves unknown: install routine codeunit "PX Install".OnInstallAppPerCompany could not run: ...
NOT RUN 50302 PX Test.ReadsTheInstallRow: (same)

What changes the outcome

What CountCompanies (the install's extra procedure) does, with the HTTP stop kept:

Install's extra procedure ReadsTheLoginRowOnly ReadsTheInstallRow
none runs not run: install routine could not run (right)
Record "PX Install Row": Get + Modify runs not run (right)
platform CopyCompany(CompanyName(), 'PX 2') runs not run (right)
Record Company: IsEmpty() only not run: PX Open Row unknown not run: PX Open Row unknown
Record Company: Get + Modify(false) not run not run
Report "Copy Company".Execute(...) not run (table API Webhook Subscription when the login inserts a row) not run

PX Open Row is never written by the install code. Only the Company record variable decides.

Expected

ReadsTheLoginRowOnly runs and ReadsTheInstallRow is refused for its own table, as on c43e4ed. The reach should add a table's event subscribers only for the events the code can raise on that record: Insert, Modify, Delete and Rename (and their *All forms), the Before and After events of each, and Validate for OnBeforeValidate and OnAfterValidate. A record that is only read raises none.

A second, smaller point: Copy Company and the subscribers of its events write the new company's rows (ChangeCompany, "Company Name" := NewCompanyName). They are counted as rows of the session company. The repro does not depend on this.

Impact

All 2112 tests of a closed-source suite are refused (106 passed on c43e4ed). Two more closed-source suites lose all their passes with the same refusal on API Webhook Subscription: 9187 tests (312 passed before) and 1086 tests (12 passed before). Their install stops at a Key Vault secret, which is out of scope, but before this build their tests that never read those rows ran.

Activity

  1. StefanMaron commented on Nov 17, 2026

    @StefanMaron
    Collaborator

    Thanks for the clear report and the repro. This refuses every test of your suite, so it goes ahead of the other open work in this area. An agent is working on it now, together with the other open test-isolation issues. I'll comment here when the fix is in a pull request.

  2. StefanMaron commented on Nov 18, 2026

    @StefanMaron
    Collaborator

    Your analysis is right. Reads do not raise table events on BC. I measured this with a corpus probe (corpus PR 1431), and the runner now uses it.

    What changes with PR 8275:

    • When an install routine stops early, the runner no longer counts the table-event subscribers of a table that the rest of the install code only reads.
    • In your repro, ReadsTheLoginRowOnly now runs and passes. The summary counts it as "1 flagged": the pass depends on that probe, which is not merged into the corpus yet.
    • ReadsTheInstallRow stays not run. The install code would have written that row, and it did not run.
    • From your table: "Company Get + Modify(false)" and "Report Copy Company.Execute" stay not run, because they write Company.

    The fix covers install code that only reads the table, through plain record variables declared in the procedure. If any code the install reaches also writes that table, uses a RecordRef on it, or runs another object, the runner treats it as before.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions