From 808e3e85fa43bb4b01687f2f503e0c93f032c3b9 Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 17:28:19 +0100 Subject: [PATCH 1/6] Check the query of its number in a static Query.SaveAsCsv and SaveAsXml The static calls ran the permission check against Session::query_object, which only instance calls set, so the check used the last query of the session or object 0. query_rows now takes the query object; the field is gone. Both static calls look the id up through one function that refuses a query of an uncompiled dependency app and an id a skipped dependency app may own, instead of answering No (al-runner issue 7612). --- crates/al-test-cli/tests/suite/main.rs | 1 + .../suite/query_static_save_permission.rs | 84 +++++++++++++++ .../tests/suite/y48_platform_probes.rs | 22 ++++ crates/al-vm/src/install_left.rs | 2 - crates/al-vm/src/lib.rs | 3 - crates/al-vm/src/queries.rs | 100 ++++++++---------- 6 files changed, 152 insertions(+), 60 deletions(-) create mode 100644 crates/al-test-cli/tests/suite/query_static_save_permission.rs diff --git a/crates/al-test-cli/tests/suite/main.rs b/crates/al-test-cli/tests/suite/main.rs index 555977784..d1f1caa44 100644 --- a/crates/al-test-cli/tests/suite/main.rs +++ b/crates/al-test-cli/tests/suite/main.rs @@ -231,6 +231,7 @@ mod sub_page_link_quoted_option_member; mod subpagelink_field_filter; mod system_flowfield_permission; mod system_table_permission_answer; +mod query_static_save_permission; mod temp_list_key_open; mod tenant_permission_set_delete; mod test_framework_refusals; diff --git a/crates/al-test-cli/tests/suite/query_static_save_permission.rs b/crates/al-test-cli/tests/suite/query_static_save_permission.rs new file mode 100644 index 000000000..19e84371e --- /dev/null +++ b/crates/al-test-cli/tests/suite/query_static_save_permission.rs @@ -0,0 +1,84 @@ +//! A static `Query.SaveAsCsv(Number, OutStream)` and `Query.SaveAsXml(Number, OutStream)` under a restricted set check the +//! query of that number, not the query of the last instance call in the session (al-runner issue 7612). The check is the one +//! `Query.Open` takes (Y24PermExecute.al:62-63, Query Execute denied). + +use super::y48_platform_probes::{outcomes, outcomes_edited}; +use al_test_cli::report::Outcome; + +const SRC: &str = r#" +dotnet { assembly("Microsoft.Dynamics.Nav.PermissionTestHelper") { + type("Microsoft.Dynamics.Nav.Runtime.PermissionTestHelper"; "PermissionTestHelper") { } } } +table 50100 "Q Row" { fields { field(1; Id; Integer) { } field(2; Data; Blob) { } } keys { key(PK; Id) { Clustered = true; } } } +query 50100 "Granted Q" { elements { dataitem(R; "Q Row") { column(Id; Id) { } } } } +query 50101 "Denied Q" { elements { dataitem(R; "Q Row") { column(Id; Id) { } } } } +permissionset 50100 "NARROW" { Assignable = true; Permissions = tabledata "Q Row" = R, query "Granted Q" = X, codeunit T = X; } +codeunit 50000 T { Subtype = Test; TestPermissions = Disabled; + local procedure Restrict() var H: DotNet PermissionTestHelper; begin + H := H.PermissionTestHelper(); H.AddEffectivePermissionSet('NARROW'); end; + [Test] procedure CsvOfDeniedFirst() var Row: Record "Q Row" temporary; OutS: OutStream; begin + Restrict(); Row.Data.CreateOutStream(OutS); + asserterror Query.SaveAsCsv(Query::"Denied Q", OutS); Error(GetLastErrorCode()); end; + [Test] procedure CsvOfDeniedAfterGranted() var Row: Record "Q Row" temporary; Q: Query "Granted Q"; OutS: OutStream; begin + Restrict(); Q.Open(); Q.Close(); Row.Data.CreateOutStream(OutS); + asserterror Query.SaveAsCsv(Query::"Denied Q", OutS); Error(GetLastErrorCode()); end; + [Test] procedure XmlOfDeniedAfterGranted() var Row: Record "Q Row" temporary; Q: Query "Granted Q"; OutS: OutStream; begin + Restrict(); Q.Open(); Q.Close(); Row.Data.CreateOutStream(OutS); + asserterror Query.SaveAsXml(Query::"Denied Q", OutS); Error(GetLastErrorCode()); end; + [Test] procedure CsvOfGranted() var Row: Record "Q Row" temporary; OutS: OutStream; begin + Restrict(); Row.Data.CreateOutStream(OutS); + if Query.SaveAsCsv(Query::"Granted Q", OutS) then Error('saved'); Error('not saved'); end; +} +"#; + +#[test] +fn static_save_as_checks_the_query_of_its_number() { + let o = outcomes(SRC); + let get = |name: &str| { + &o.iter() + .find(|(n, _)| n == name) + .unwrap_or_else(|| panic!("{name} in {o:?}")) + .1 + }; + for name in ["CsvOfDeniedFirst", "CsvOfDeniedAfterGranted", "XmlOfDeniedAfterGranted"] { + assert_eq!(*get(name), Outcome::Fail("DB:ExecuteObjDenied".into()), "{name}"); + } + assert_eq!(*get("CsvOfGranted"), Outcome::Fail("saved".into())); +} + +const SHELL_SRC: &str = r#" +table 50100 "Q Row" { fields { field(1; Id; Integer) { } field(2; Data; Blob) { } } keys { key(PK; Id) { Clustered = true; } } } +query 50102 "Shell Q" { elements { dataitem(R; "Q Row") { column(Id; Id) { } } } } +codeunit 50000 T { Subtype = Test; + [Test] procedure CsvOfShell() var Row: Record "Q Row" temporary; OutS: OutStream; begin + Row.Data.CreateOutStream(OutS); if Query.SaveAsCsv(50102, OutS) then Error('saved'); Error('not saved'); end; + [Test] procedure XmlOfShell() var Row: Record "Q Row" temporary; OutS: OutStream; begin + Row.Data.CreateOutStream(OutS); if Query.SaveAsXml(50102, OutS) then Error('saved'); Error('not saved'); end; + [Test] procedure CsvOfUnknown() var Row: Record "Q Row" temporary; OutS: OutStream; begin + Row.Data.CreateOutStream(OutS); if Query.SaveAsCsv(50199, OutS) then Error('saved'); Error('not saved'); end; +} +"#; + +/// A query of a dependency app that was not compiled is refused (BC finds it); an unknown id keeps main's No +/// (xmlports/import/XpTQuerySave.al:SaveAsCsv_UnknownQueryId) unless the run skipped a dependency app. +#[test] +fn static_save_as_of_an_uncompiled_or_skipped_query_refuses() { + let shell = |p: &mut al_ir::Program| { + let i = p.objects.iter().position(|o| o.name == "Shell Q").expect("Shell Q"); + p.objects[i].uncompiled = true; + }; + let o = outcomes_edited(SHELL_SRC, shell, Vec::new()); + let get = |o: &[(String, Outcome)], name: &str| o.iter().find(|(n, _)| n == name).expect(name).1.clone(); + for name in ["CsvOfShell", "XmlOfShell"] { + match get(&o, name) { + Outcome::NotRun(why) => assert!(why.contains("was not compiled"), "{name}: {why}"), + other => panic!("{name}: {other:?}"), + } + } + assert_eq!(get(&o, "CsvOfUnknown"), Outcome::Fail("not saved".into())); + let o = outcomes_edited(SHELL_SRC, |_| {}, vec!["`Dep` by Publisher".into()]); + match get(&o, "CsvOfUnknown") { + Outcome::NotRun(why) => assert!(why.contains("skipped the dependency"), "{why}"), + other => panic!("{other:?}"), + } + assert_eq!(get(&o, "CsvOfShell"), Outcome::Fail("saved".into())); +} diff --git a/crates/al-test-cli/tests/suite/y48_platform_probes.rs b/crates/al-test-cli/tests/suite/y48_platform_probes.rs index 97b9fc0fa..d32272246 100644 --- a/crates/al-test-cli/tests/suite/y48_platform_probes.rs +++ b/crates/al-test-cli/tests/suite/y48_platform_probes.rs @@ -78,6 +78,27 @@ pub(crate) fn outcomes_with_hits_app( /// `main` as the app `app_id` on the System app, compiled, and an engine for it that runs as BC 27.5. fn compile_on_system(app_id: &str, main: &str) -> (std::sync::Arc, al_sema::lower::Lowered) { + compile_on_system_edited(app_id, main, |_| {}) +} + +/// [`outcomes`] of a program changed by `edit` before the engine is made, with `skipped` as the dependency apps the run +/// skipped (`Engine::skipped_apps`): for shapes a source alone does not make, such as a shell of an uncompiled app. +pub(crate) fn outcomes_edited( + main: &str, + edit: impl FnOnce(&mut al_ir::Program), + skipped: Vec, +) -> Vec<(String, Outcome)> { + let (mut engine, l) = compile_on_system_edited("main", main, edit); + std::sync::Arc::get_mut(&mut engine).expect("not shared").skipped_apps = skipped; + let oi = l.program.objects.iter().position(|o| o.name == "T").expect("test codeunit T"); + run_codeunit(&engine, &l, oi) +} + +fn compile_on_system_edited( + app_id: &str, + main: &str, + edit: impl FnOnce(&mut al_ir::Program), +) -> (std::sync::Arc, al_sema::lower::Lowered) { use al_sema::workspace::{AppKind, AppSource}; let app = |id: &str, name: &str, files: Vec<(String, String)>| AppSource { id: id.into(), @@ -106,6 +127,7 @@ fn compile_on_system(app_id: &str, main: &str) -> (std::sync::Arc, al_se for a in program.apps.iter_mut().filter(|a| a.version.is_empty()) { a.version = "1.0.0.0".into(); } + edit(&mut program); let engine = Engine::with_target( std::sync::Arc::new(program), blocked, diff --git a/crates/al-vm/src/install_left.rs b/crates/al-vm/src/install_left.rs index 4929e9f15..f2b44a4f8 100644 --- a/crates/al-vm/src/install_left.rs +++ b/crates/al-vm/src/install_left.rs @@ -180,8 +180,6 @@ impl Session { report_refusal_after_denial: _, permission_caller: _, permission_run_object: _, - // Set before each query method call that reads it. - query_object: _, query_receiver: _, keyref_receiver_local: _, test_object: _, diff --git a/crates/al-vm/src/lib.rs b/crates/al-vm/src/lib.rs index 3691fe3f2..a3e1cd76d 100644 --- a/crates/al-vm/src/lib.rs +++ b/crates/al-vm/src/lib.rs @@ -1064,8 +1064,6 @@ pub struct Session { pub(crate) permission_caller: Option, /// The xmlport whose export runs: the reads the runtime makes for it (not AL code) are decided as that object's. pub(crate) permission_run_object: Option, - /// The query whose method runs (the object index), for the read check of `query_rows`. - pub(crate) query_object: usize, /// The global variable (object index of the routine, slot) a query method is called on, from `run_native` to `query_op`. pub(crate) query_receiver: Option<(usize, usize)>, /// The KeyRef method that runs was called on a declared local variable of a codeunit procedure, from `run_native` to @@ -1454,7 +1452,6 @@ impl Session { report_refusal_after_denial: None, permission_caller: None, permission_run_object: None, - query_object: 0, query_receiver: None, keyref_receiver_local: false, permissions: None, diff --git a/crates/al-vm/src/queries.rs b/crates/al-vm/src/queries.rs index 3c25bab3f..66faea5a3 100644 --- a/crates/al-vm/src/queries.rs +++ b/crates/al-vm/src/queries.rs @@ -174,7 +174,6 @@ impl Session { }; let engine = self.engine.clone(); let object = qs.borrow().object as usize; - self.query_object = object; let def = engine.program.objects[object].query.as_ref().expect("a query object"); for a in &def.assumes { al_builtins::assumptions::assume(*a); @@ -422,7 +421,7 @@ impl Session { "SaveAsCsv" => { let filters = qs.borrow().filters.clone(); let top = qs.borrow().top.unwrap_or(def.top); - self.query_save_csv(def, &filters, top, args) + self.query_save_csv(object, def, &filters, top, args) } other => unsupported(format!("Query.{other}")), } @@ -434,11 +433,13 @@ impl Session { fn query_save_as(&mut self, def: &ir::Query, qs: &Qs, method: &str, args: &[Value]) -> Result { let filters = qs.borrow().filters.clone(); let top = qs.borrow().top.unwrap_or(def.top); - self.query_save_as_with(def, &filters, top, method, args.first()) + let object = qs.borrow().object as usize; + self.query_save_as_with(object, def, &filters, top, method, args.first()) } fn query_save_as_with( &mut self, + object: usize, def: &ir::Query, filters: &[(usize, FilterExpr)], top: i32, @@ -459,7 +460,7 @@ impl Session { .iter() .map(|&c| (def.columns[c].name.as_str(), &def.columns[c].ty)) .collect(); - let (rows, _) = self.query_rows(def, filters)?; + let (rows, _) = self.query_rows(object, def, filters)?; let rows: Vec> = rows .iter() .take(if top > 0 { top as usize } else { usize::MAX }) @@ -470,56 +471,48 @@ impl Session { Ok(Value::Boolean(true)) } - /// `Query.SaveAsXml(Number, OutStream)` of an id no query has: No, and nothing raises - /// (reports/request-page/P105QryXml.al:163-177). With the answer dropped it raises MetadataNotFound - /// (queries/CgQueryLeads.al:656-690), which is not built: refused. - fn query_save_xml_static_op(&mut self, args: &[Value]) -> Result { - let known = match args.first() { - Some(Value::Integer(id)) => self - .engine - .program - .objects - .heads() - .iter() - .any(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == u32::try_from(*id).ok()), - _ => return unsupported("Query.SaveAsXml with an id that is not an integer"), - }; - // Of a query: the file of the instance call with no filters, and Yes - // (reports/request-page/P105QryXmlContentSM.al:115-131 SaveAsXml_Static_Content). - if known { - return self.query_save_xml_static(args); - } - if !self.ret_used { - return unsupported( - "Query.SaveAsXml(Number, OutStream) of an unknown id with the answer dropped (not pinned)", - ); + /// The query object of a static `Query.SaveAsXml` or `Query.SaveAsCsv` with the id `id`: `Some` for a compiled query, + /// `None` for an id no loaded app declares. A query of a dependency app that was not compiled, and an id that may belong + /// to a dependency app the run skipped, are refused: BC finds that query, writes its file and answers Yes. + fn query_static_object(&self, method: &str, id: i64) -> Result, Signal> { + let heads = self.engine.program.objects.heads(); + let want = u32::try_from(id).ok(); + if let Some(object) = heads.iter().position(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == want) { + return Ok(Some(object)); + } + if heads.iter().any(|o| o.is_shell_of(al_ir::ObjKind::Query) && o.id == want) { + return unsupported(format!( + "Query.{method} of query {id}, which belongs to a dependency app and was not compiled (no code the workspace reaches uses it)" + )); } - if let Some(Value::Integer(id)) = args.first() - && let Some(why) = self.missing_may_be_skipped("Query", i64::from(*id)) - { + if let Some(why) = self.missing_may_be_skipped("Query", id) { return unsupported(why); } - Ok(Value::Boolean(false)) + Ok(None) } - /// `Query.SaveAsXml(Number, OutStream)` of a query object. - fn query_save_xml_static(&mut self, args: &[Value]) -> Result { + /// `Query.SaveAsXml(Number, OutStream)`. Of a query: the file of the instance call with no filters, and Yes + /// (reports/request-page/P105QryXmlContentSM.al:115-131 SaveAsXml_Static_Content). Of an id no query has: No, and + /// nothing raises (reports/request-page/P105QryXml.al:163-177). With the answer dropped that raises MetadataNotFound + /// (queries/CgQueryLeads.al:656-690), which is not built: refused. + fn query_save_xml_static_op(&mut self, args: &[Value]) -> Result { let Some(Value::Integer(id)) = args.first() else { return unsupported("Query.SaveAsXml with an id that is not an integer"); }; + let Some(object) = self.query_static_object("SaveAsXml", i64::from(*id))? else { + if !self.ret_used { + return unsupported( + "Query.SaveAsXml(Number, OutStream) of an unknown id with the answer dropped (not pinned)", + ); + } + return Ok(Value::Boolean(false)); + }; let engine = self.engine.clone(); - let def = engine - .program - .objects - .heads() - .iter() - .position(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == u32::try_from(*id).ok()) - .and_then(|o| engine.program.objects[o].query.as_ref()) - .expect("a known query"); + let def = engine.program.objects[object].query.as_ref().expect("a query object"); for a in &def.assumes { al_builtins::assumptions::assume(*a); } - self.query_save_as_with(def, &[], def.top, "SaveAsXml", args.get(1)) + self.query_save_as_with(object, def, &[], def.top, "SaveAsXml", args.get(1)) } /// `Query.SaveAsCsv(Number, OutStream)`: the query of that id with no filters. An id no query has writes nothing and @@ -529,21 +522,15 @@ impl Session { Some(Value::Integer(n)) => *n, other => return unsupported(format!("Query.SaveAsCsv with {}", other.describe())), }; - let engine = self.engine.clone(); - let Some(object) = engine - .program - .objects - .heads() - .iter() - .position(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == u32::try_from(id).ok()) - else { + let Some(object) = self.query_static_object("SaveAsCsv", i64::from(id))? else { return Ok(Value::Boolean(false)); }; + let engine = self.engine.clone(); let def = engine.program.objects[object].query.as_ref().expect("a query object"); for a in &def.assumes { al_builtins::assumptions::assume(*a); } - self.query_save_csv(def, &[], def.top, &args[1..]) + self.query_save_csv(object, def, &[], def.top, &args[1..]) } /// The rows of a query as CSV: the column names, then a row per line, each line ended by a line feed. A text with a comma or a @@ -551,6 +538,7 @@ impl Session { /// Other column types are not pinned. fn query_save_csv( &mut self, + object: usize, def: &ir::Query, filters: &[(usize, FilterExpr)], top: i32, @@ -598,7 +586,7 @@ impl Session { )); } } - let (rows, _) = self.query_rows(def, filters)?; + let (rows, _) = self.query_rows(object, def, filters)?; // The file of queries/W7QueryLifecycle.al:SaveAsCsv_NonIntegerColumns (a Date column and a text with an accent) is 83 bytes // where this writes 81; which of the two accounts for the difference is not pinned, so neither is written. if rows.iter().any(|r| { @@ -889,7 +877,7 @@ impl Session { } if !qs.borrow().run.as_ref().expect("open").started { let filters = qs.borrow().filters.clone(); - let (rows, stamps) = self.query_rows(def, &filters)?; + let (rows, stamps) = self.query_rows(qs.borrow().object as usize, def, &filters)?; let mut q = qs.borrow_mut(); let run = q.run.as_mut().expect("open"); run.rows = rows; @@ -905,7 +893,7 @@ impl Session { return unsupported("a write to a table an open aggregated query reads (the re-read is not pinned)"); } let filters = qs.borrow().filters.clone(); - let (mut rows, stamps) = self.query_rows(def, &filters)?; + let (mut rows, stamps) = self.query_rows(qs.borrow().object as usize, def, &filters)?; let dirs: Vec = def.order_by.iter().map(|(_, asc)| *asc).collect(); let mut q = qs.borrow_mut(); let run = q.run.as_mut().expect("open"); @@ -1000,14 +988,16 @@ impl Session { } /// Runs the query: its rows in order, and the table versions they were read at. + /// `object`: the query object, whose Execute permission and table reads are checked. fn query_rows( &mut self, + object: usize, def: &ir::Query, runtime: &[(usize, FilterExpr)], ) -> Result<(Vec, Stamps), Signal> { if self.permission_checks() { let tables: Vec = def.items.iter().map(|i| i.table).collect(); - self.permission_gate_object_read(self.query_object, &tables)?; + self.permission_gate_object_read(object, &tables)?; } let stamps = self.query_stamps(def); for (table, _) in &stamps { From 58f85d4ac5e0922244b9390f33ba28265a6471d2 Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 17:38:14 +0100 Subject: [PATCH 2/6] Let the API webhook setup read of an empty table pass under a restricted set The first write of an own table under a Permissions Mock set asks the table's database trigger setup; Base Application's API Webhook Notification Mgt. then asks IsEmpty of API Webhook Subscription, which the set does not grant. BC raises no error there (permissions/SysFlowFieldPerm.al:489-499); the runtime refused the test. Only that read, from codeunit 6153, while a setup is asked, on a table with no row, now runs. Five SysFlowFieldPerm cases pass on BC 28 (al-runner issue 8038). --- crates/al-vm/src/globaltriggers.rs | 2 + crates/al-vm/src/install_left/clients.rs | 2 + crates/al-vm/src/lib.rs | 2 + crates/al-vm/src/permission_trigger_setup.rs | 50 ++++++++++++++++++++ crates/al-vm/src/permissions.rs | 3 ++ crates/al-vm/src/state.rs | 3 ++ 6 files changed, 62 insertions(+) create mode 100644 crates/al-vm/src/permission_trigger_setup.rs diff --git a/crates/al-vm/src/globaltriggers.rs b/crates/al-vm/src/globaltriggers.rs index a3a7b1bb8..62de25846 100644 --- a/crates/al-vm/src/globaltriggers.rs +++ b/crates/al-vm/src/globaltriggers.rs @@ -139,7 +139,9 @@ impl Session { sender: None, }; self.events.setup_no_ops = self.setup_subscribers_changing_nothing(id); + let outer = self.events.db_setup_table.replace(table); let raised = self.raise_global(&call, &mut args); + self.events.db_setup_table = outer; self.events.setup_no_ops.clear(); if let Err(e) = raised { self.events.global_setups.remove(&table); diff --git a/crates/al-vm/src/install_left/clients.rs b/crates/al-vm/src/install_left/clients.rs index 87be0fbfc..aa8ac31d8 100644 --- a/crates/al-vm/src/install_left/clients.rs +++ b/crates/al-vm/src/install_left/clients.rs @@ -116,6 +116,7 @@ pub(super) fn events_as_new(e: &EventState) -> bool { install_written, install_rows, setup_no_ops, + db_setup_table, trial, global_setups, } = e; @@ -161,6 +162,7 @@ pub(super) fn events_as_new(e: &EventState) -> bool { && install_written.is_none() && install_rows.is_none() && setup_no_ops.is_empty() + && db_setup_table.is_none() && !allowed && picked.is_empty() && *depth == 0 diff --git a/crates/al-vm/src/lib.rs b/crates/al-vm/src/lib.rs index a3e1cd76d..7b79e4886 100644 --- a/crates/al-vm/src/lib.rs +++ b/crates/al-vm/src/lib.rs @@ -110,6 +110,7 @@ mod partial; mod permission_bulk_no_match; mod permission_shadow; mod permission_system_flowfield; +mod permission_trigger_setup; mod permission_triggers; mod permissions; mod platform; @@ -1513,6 +1514,7 @@ impl Session { install_written: None, install_rows: None, setup_no_ops: Default::default(), + db_setup_table: None, trial: Default::default(), global_setups: Default::default(), }, diff --git a/crates/al-vm/src/permission_trigger_setup.rs b/crates/al-vm/src/permission_trigger_setup.rs new file mode 100644 index 000000000..08fe4c5a1 --- /dev/null +++ b/crates/al-vm/src/permission_trigger_setup.rs @@ -0,0 +1,50 @@ +//! A read that the code answering `Global Triggers.GetDatabaseTableTriggerSetup` makes under a restricted set, which the +//! session's sets do not grant (ADR-062). Only the measured read runs: Base Application's `API Webhook Notification Mgt.` +//! asks `IsEmpty` of "API Webhook Subscription" when the first write of an own table under a Permissions Mock set asks the +//! table's setup, and that table holds no row. BC raises no error there and the write goes on +//! (permissions/SysFlowFieldPerm.al:489-499: `Item.DeleteAll` of `Op`, the first write of "SFP Item" in each case, under +//! "SFP PA READ" and "SFP NO PA", neither of which grants the table). With no row, the table enables no database trigger +//! whichever way BC answers the read. Every other read keeps the refusal of `Session::write_denied`. + +use crate::Session; +use crate::permissions::{Access, Op}; +use crate::records::Rec; +use al_builtins::native::Signal; +use al_builtins::record_op::RecordOp; + +/// "API Webhook Subscription". +const API_WEBHOOK_SUBSCRIPTION: u32 = 2_000_000_095; +/// Base Application's "API Webhook Notification Mgt.", whose `GetDatabaseTableTriggerSetup` reads it. +const API_WEBHOOK_NOTIFICATION_MGT: u32 = 6153; + +impl Session { + /// Whether the denied `access` by the record method `method` on `rec` is the measured read above. Every fact is + /// required by equality: the setup of a table is being asked (`EventState::db_setup_table`), the method is `IsEmpty`, + /// the access a read of "API Webhook Subscription", the running code is codeunit 6153, and the table holds no row in + /// the record's company. + pub(crate) fn trigger_setup_read_unchecked( + &mut self, + method: RecordOp, + rec: &Rec, + access: Access, + ) -> Result { + let heads = self.engine.program.objects.heads(); + let caller_is_mgt = self.frames.last().is_some_and(|&o| { + heads[o].is_kind(al_ir::ObjKind::Codeunit) && heads[o].id == Some(API_WEBHOOK_NOTIFICATION_MGT) + }); + let measured = self.events.db_setup_table.is_some() + && method == RecordOp::IsEmpty + && access.op == Op::Read + && access.kind == 0 + && access.id == API_WEBHOOK_SUBSCRIPTION + && caller_is_mgt; + if !measured { + return Ok(false); + } + let t = self.table(rec)?; + let cx = self.cx_for(rec, &t)?; + let rows = al_data::Store::count(&*self.store_for(rec)?, &cx, &t, &[]) + .map_err(|e| Signal::unsupported(format!("store error {e}")))?; + Ok(rows == 0) + } +} diff --git a/crates/al-vm/src/permissions.rs b/crates/al-vm/src/permissions.rs index 306886544..983eb258d 100644 --- a/crates/al-vm/src/permissions.rs +++ b/crates/al-vm/src/permissions.rs @@ -1592,6 +1592,9 @@ impl Session { if !from_al { return refuse("made by the runtime for a page, report, xmlport or validation; ADR-062 probes P16-P18"); } + if access.op == Op::Read && self.trigger_setup_read_unchecked(method, rec, access)? { + return Ok(()); + } if access.id >= 2_000_000_000 && access.id != TENANT_MEDIA { return refuse("on a system table; probe P13 pins Tenant Media only"); } diff --git a/crates/al-vm/src/state.rs b/crates/al-vm/src/state.rs index b0f7da31e..38e6185d8 100644 --- a/crates/al-vm/src/state.rs +++ b/crates/al-vm/src/state.rs @@ -408,6 +408,9 @@ pub(crate) struct EventState { /// subscribers of `order_unknown_apps` that leave every flag unchanged for it (setup_no_op.rs), or do nothing for it /// (db_event_no_op.rs), which the raise leaves out instead of refusing. pub(crate) setup_no_ops: std::collections::BTreeSet<(usize, usize)>, + /// While the subscribers of `GetDatabaseTableTriggerSetup` answer for one table: that table (object index), for the read + /// they make under a restricted set (permission_trigger_setup.rs). + pub(crate) db_setup_table: Option, /// The trial runs of subscribers whose install order is not known (order_trial.rs). pub(crate) trial: crate::order_trial::TrialState, /// What the subscribers of `Global Triggers` answered, per table object (globaltriggers.rs). From 772756031dfabeb2ab5065abd4b45f30d3da4640 Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 17:43:01 +0100 Subject: [PATCH 3/6] Prune the cases that pass now and format 98743 PARead cases (five per major) and 60026 MockedSet_WithTheGrant_AllowsInsert (BC 28 and 29) pass with the API webhook setup read. --- crates/al-test-cli/tests/suite/main.rs | 2 +- crates/al-test-cli/tests/suite/y48_platform_probes.rs | 7 ++++++- crates/al-vm/src/queries.rs | 10 ++++++++-- metrics/27/not-passing-onprem.txt | 5 ----- metrics/28/not-passing-onprem.txt | 5 ----- metrics/28/not-passing.txt | 1 - metrics/29/not-passing-onprem.txt | 5 ----- metrics/29/not-passing.txt | 1 - 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/crates/al-test-cli/tests/suite/main.rs b/crates/al-test-cli/tests/suite/main.rs index d1f1caa44..c0156a057 100644 --- a/crates/al-test-cli/tests/suite/main.rs +++ b/crates/al-test-cli/tests/suite/main.rs @@ -174,6 +174,7 @@ mod provider_no_row_7392; mod query_close_error_last_error; mod query_outer_flow; mod query_reopen_rows_left; +mod query_static_save_permission; mod quoted_ident; mod r1b_page_moves; mod readable_messages; @@ -231,7 +232,6 @@ mod sub_page_link_quoted_option_member; mod subpagelink_field_filter; mod system_flowfield_permission; mod system_table_permission_answer; -mod query_static_save_permission; mod temp_list_key_open; mod tenant_permission_set_delete; mod test_framework_refusals; diff --git a/crates/al-test-cli/tests/suite/y48_platform_probes.rs b/crates/al-test-cli/tests/suite/y48_platform_probes.rs index d32272246..0190593ea 100644 --- a/crates/al-test-cli/tests/suite/y48_platform_probes.rs +++ b/crates/al-test-cli/tests/suite/y48_platform_probes.rs @@ -90,7 +90,12 @@ pub(crate) fn outcomes_edited( ) -> Vec<(String, Outcome)> { let (mut engine, l) = compile_on_system_edited("main", main, edit); std::sync::Arc::get_mut(&mut engine).expect("not shared").skipped_apps = skipped; - let oi = l.program.objects.iter().position(|o| o.name == "T").expect("test codeunit T"); + let oi = l + .program + .objects + .iter() + .position(|o| o.name == "T") + .expect("test codeunit T"); run_codeunit(&engine, &l, oi) } diff --git a/crates/al-vm/src/queries.rs b/crates/al-vm/src/queries.rs index 66faea5a3..058273db1 100644 --- a/crates/al-vm/src/queries.rs +++ b/crates/al-vm/src/queries.rs @@ -477,10 +477,16 @@ impl Session { fn query_static_object(&self, method: &str, id: i64) -> Result, Signal> { let heads = self.engine.program.objects.heads(); let want = u32::try_from(id).ok(); - if let Some(object) = heads.iter().position(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == want) { + if let Some(object) = heads + .iter() + .position(|o| o.is_kind(al_ir::ObjKind::Query) && o.id == want) + { return Ok(Some(object)); } - if heads.iter().any(|o| o.is_shell_of(al_ir::ObjKind::Query) && o.id == want) { + if heads + .iter() + .any(|o| o.is_shell_of(al_ir::ObjKind::Query) && o.id == want) + { return unsupported(format!( "Query.{method} of query {id}, which belongs to a dependency app and was not compiled (no code the workspace reaches uses it)" )); diff --git a/metrics/27/not-passing-onprem.txt b/metrics/27/not-passing-onprem.txt index 474039e33..2d8d35b8c 100644 --- a/metrics/27/not-passing-onprem.txt +++ b/metrics/27/not-passing-onprem.txt @@ -205,11 +205,6 @@ 98743 NoPA_NotFound_CalcExistCount 98743 NoPA_NotFound_CalcNamePublisher 98743 PARead_Found_AutoCalcAndFilter -98743 PARead_Found_CalcExistCount -98743 PARead_Found_CalcNamePublisher -98743 PARead_NotFound_AutoCalcAndFilter -98743 PARead_NotFound_CalcExistCount -98743 PARead_NotFound_CalcNamePublisher 98747 NoPA_Found_A 98747 NoPA_Found_B 98747 NoPA_NotFound_A diff --git a/metrics/28/not-passing-onprem.txt b/metrics/28/not-passing-onprem.txt index ff34045c9..3006c1ec9 100644 --- a/metrics/28/not-passing-onprem.txt +++ b/metrics/28/not-passing-onprem.txt @@ -206,11 +206,6 @@ 98743 NoPA_NotFound_CalcExistCount 98743 NoPA_NotFound_CalcNamePublisher 98743 PARead_Found_AutoCalcAndFilter -98743 PARead_Found_CalcExistCount -98743 PARead_Found_CalcNamePublisher -98743 PARead_NotFound_AutoCalcAndFilter -98743 PARead_NotFound_CalcExistCount -98743 PARead_NotFound_CalcNamePublisher 98747 NoPA_Found_A 98747 NoPA_Found_B 98747 NoPA_NotFound_A diff --git a/metrics/28/not-passing.txt b/metrics/28/not-passing.txt index 07cb1bf4b..3d484dbac 100644 --- a/metrics/28/not-passing.txt +++ b/metrics/28/not-passing.txt @@ -11,7 +11,6 @@ 51762 TestPage_OpenNew_VariableControlCanModifyDocument 51774 ModalWorksheetWithNoMatchingRows 51775 DirectTenantMediaInsertKeepsExplicitZeroGuid -60026 MockedSet_WithTheGrant_AllowsInsert 60129 Record_Relation_EntryNoField_Throws 60129 Record_Relation_NonRelatedField_Throws 60130 Media_ExportStream_ValidPng_RoundTripsPreservingDimensions diff --git a/metrics/29/not-passing-onprem.txt b/metrics/29/not-passing-onprem.txt index 1606d6e36..ebbb0681b 100644 --- a/metrics/29/not-passing-onprem.txt +++ b/metrics/29/not-passing-onprem.txt @@ -205,11 +205,6 @@ 98743 NoPA_NotFound_CalcExistCount 98743 NoPA_NotFound_CalcNamePublisher 98743 PARead_Found_AutoCalcAndFilter -98743 PARead_Found_CalcExistCount -98743 PARead_Found_CalcNamePublisher -98743 PARead_NotFound_AutoCalcAndFilter -98743 PARead_NotFound_CalcExistCount -98743 PARead_NotFound_CalcNamePublisher 98747 NoPA_Found_A 98747 NoPA_Found_B 98747 NoPA_NotFound_A diff --git a/metrics/29/not-passing.txt b/metrics/29/not-passing.txt index fbce4bbf7..213b7f4b3 100644 --- a/metrics/29/not-passing.txt +++ b/metrics/29/not-passing.txt @@ -11,7 +11,6 @@ 51762 TestPage_OpenNew_VariableControlCanModifyDocument 51774 ModalWorksheetWithNoMatchingRows 51775 DirectTenantMediaInsertKeepsExplicitZeroGuid -60026 MockedSet_WithTheGrant_AllowsInsert 60129 Record_Relation_EntryNoField_Throws 60129 Record_Relation_NonRelatedField_Throws 60130 Media_ExportStream_ValidPng_RoundTripsPreservingDimensions From 49a836f4e1a32bed5868431e8e1180a5241589bf Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 18:54:32 +0100 Subject: [PATCH 4/6] Require Base Application's codeunit 6153 for the setup read and test its neighbors The setup read of API Webhook Subscription now also requires that codeunit 6153 belongs to Base Application. A Rust test shows the empty-table read passes, and that a table with a row, FindFirst, another caller and a codeunit 6153 of another app keep main's refusal. --- crates/al-test-cli/tests/suite/main.rs | 1 + .../suite/trigger_setup_read_permission.rs | 70 +++++++++++++++++++ crates/al-vm/src/permission_trigger_setup.rs | 12 +++- 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 crates/al-test-cli/tests/suite/trigger_setup_read_permission.rs diff --git a/crates/al-test-cli/tests/suite/main.rs b/crates/al-test-cli/tests/suite/main.rs index c0156a057..1a96303cc 100644 --- a/crates/al-test-cli/tests/suite/main.rs +++ b/crates/al-test-cli/tests/suite/main.rs @@ -238,6 +238,7 @@ mod test_framework_refusals; mod test_handlers; mod testpage_action_without_parentheses; mod this_in_objects; +mod trigger_setup_read_permission; mod typed_handler_set_up_variable; mod typed_handler_temp_stored_source; mod unpinned_error_result; diff --git a/crates/al-test-cli/tests/suite/trigger_setup_read_permission.rs b/crates/al-test-cli/tests/suite/trigger_setup_read_permission.rs new file mode 100644 index 000000000..aabda4db6 --- /dev/null +++ b/crates/al-test-cli/tests/suite/trigger_setup_read_permission.rs @@ -0,0 +1,70 @@ +//! The read Base Application's "API Webhook Notification Mgt." (codeunit 6153) makes while it answers +//! `Global Triggers.GetDatabaseTableTriggerSetup` under a restricted set: `IsEmpty` of "API Webhook Subscription" with no row +//! passes (permissions/SysFlowFieldPerm.al:489-499). Every neighbor keeps main's refusal: a table with a row, another +//! method, another caller, and a codeunit 6153 of an app that is not Base Application. + +use super::y48_platform_probes::outcomes_with_hits_app; +use al_test_cli::report::Outcome; + +/// An app with an own table, a subscriber `caller` whose setup answer runs `body`, a set that grants the own table and runs +/// both codeunits but does not grant "API Webhook Subscription", and a test that writes the own table under that set. `seed` runs before the set applies. +fn src(caller: &str, body: &str, seed: &str) -> String { + let id = caller.split_whitespace().nth(1).expect("codeunit id"); + format!( + r#" +dotnet {{ assembly("Microsoft.Dynamics.Nav.PermissionTestHelper") {{ + type("Microsoft.Dynamics.Nav.Runtime.PermissionTestHelper"; "PermissionTestHelper") {{ }} }} }} +table 50100 "Own Row" {{ fields {{ field(1; Id; Integer) {{ }} }} keys {{ key(PK; Id) {{ Clustered = true; }} }} }} +{caller} +{{ + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Global Triggers", GetDatabaseTableTriggerSetup, '', false, false)] + local procedure GetDatabaseTableTriggerSetup(TableId: Integer; var OnDatabaseInsert: Boolean; var OnDatabaseModify: Boolean; var OnDatabaseDelete: Boolean; var OnDatabaseRename: Boolean) + var Sub: Record "API Webhook Subscription"; + begin + {body} + end; +}} +permissionset 50100 "NARROW" {{ Assignable = true; Permissions = tabledata "Own Row" = RIMD, codeunit T = X, codeunit {id} = X; }} +codeunit 50000 T {{ Subtype = Test; TestPermissions = Disabled; + [Test] procedure WriteOwn() var H: DotNet PermissionTestHelper; Row: Record "Own Row"; Sub: Record "API Webhook Subscription"; begin + {seed} + H := H.PermissionTestHelper(); H.AddEffectivePermissionSet('NARROW'); + Row.Id := 1; Row.Insert(); end; +}} +"# + ) +} + +const MGT: &str = r#"codeunit 6153 "API Webhook Notification Mgt.""#; +const OTHER: &str = r#"codeunit 50101 "Other Setup""#; +const IS_EMPTY: &str = "if Sub.IsEmpty() then;"; + +fn outcome(app_id: &str, src: &str) -> Outcome { + let o = outcomes_with_hits_app(app_id, src, "T"); + o.into_iter().find(|(n, _, _)| n == "WriteOwn").expect("WriteOwn").1 +} + +fn refused(o: Outcome, what: &str) { + match o { + Outcome::NotRun(why) => assert!(why.contains("system table"), "{what}: {why}"), + other => panic!("{what}: expected main's refusal, got {other:?}"), + } +} + +#[test] +fn setup_read_of_an_empty_table_by_base_application_passes() { + let base = al_ir::BASE_APPLICATION_APP_ID; + assert_eq!(outcome(base, &src(MGT, IS_EMPTY, "")), Outcome::Pass); +} + +#[test] +fn setup_read_neighbors_keep_the_refusal() { + let base = al_ir::BASE_APPLICATION_APP_ID; + refused( + outcome(base, &src(MGT, IS_EMPTY, "Sub.Init(); Sub.Insert();")), + "table with a row", + ); + refused(outcome(base, &src(MGT, "if Sub.FindFirst() then;", "")), "FindFirst"); + refused(outcome(base, &src(OTHER, IS_EMPTY, "")), "another caller"); + refused(outcome("main", &src(MGT, IS_EMPTY, "")), "codeunit 6153 of another app"); +} diff --git a/crates/al-vm/src/permission_trigger_setup.rs b/crates/al-vm/src/permission_trigger_setup.rs index 08fe4c5a1..e6ea3fe0b 100644 --- a/crates/al-vm/src/permission_trigger_setup.rs +++ b/crates/al-vm/src/permission_trigger_setup.rs @@ -20,7 +20,7 @@ const API_WEBHOOK_NOTIFICATION_MGT: u32 = 6153; impl Session { /// Whether the denied `access` by the record method `method` on `rec` is the measured read above. Every fact is /// required by equality: the setup of a table is being asked (`EventState::db_setup_table`), the method is `IsEmpty`, - /// the access a read of "API Webhook Subscription", the running code is codeunit 6153, and the table holds no row in + /// the access a read of "API Webhook Subscription", the running code is codeunit 6153 of Base Application, and the table holds no row in /// the record's company. pub(crate) fn trigger_setup_read_unchecked( &mut self, @@ -28,9 +28,15 @@ impl Session { rec: &Rec, access: Access, ) -> Result { - let heads = self.engine.program.objects.heads(); + let program = &self.engine.program; + let heads = program.objects.heads(); let caller_is_mgt = self.frames.last().is_some_and(|&o| { - heads[o].is_kind(al_ir::ObjKind::Codeunit) && heads[o].id == Some(API_WEBHOOK_NOTIFICATION_MGT) + heads[o].is_kind(al_ir::ObjKind::Codeunit) + && heads[o].id == Some(API_WEBHOOK_NOTIFICATION_MGT) + && program + .apps + .get(program.objects[o].app as usize) + .is_some_and(|a| a.id.eq_ignore_ascii_case(al_ir::BASE_APPLICATION_APP_ID)) }); let measured = self.events.db_setup_table.is_some() && method == RecordOp::IsEmpty From 123a2c8a601e884b546ddd8df0c7a0d1073347ca Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 19:01:44 +0100 Subject: [PATCH 5/6] Answer GetUrl of a service client type with an object and a record (5 arguments) SOAP, OData, ODataV4 and Api with a page over the record's table or a codeunit, and a Record or RecordRef that is not temporary, answer the empty text (GetUrlServiceClientRecord.al:166-182). An object that a Web Service or Tenant Web Service row names now refuses with every argument list: BC answers an address with the service name there (:311-317), which is not built. Main answered the empty text for the four-argument form of such an object. --- .../tests/suite/geturl_service_five_args.rs | 48 +++++++++++++++++ crates/al-test-cli/tests/suite/main.rs | 1 + crates/al-vm/src/geturl.rs | 52 +++++++++++++++++++ crates/al-vm/src/platform/seed.rs | 41 +++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 crates/al-test-cli/tests/suite/geturl_service_five_args.rs diff --git a/crates/al-test-cli/tests/suite/geturl_service_five_args.rs b/crates/al-test-cli/tests/suite/geturl_service_five_args.rs new file mode 100644 index 000000000..74a71637e --- /dev/null +++ b/crates/al-test-cli/tests/suite/geturl_service_five_args.rs @@ -0,0 +1,48 @@ +//! GetUrl of a service client type (SOAP, OData, ODataV4, Api) with five arguments: an object and a record, no UseFilters +//! (al-runner issue 7586 item 5). The pinned shapes answer the empty text (GetUrlServiceClientRecord.al:166-182); their +//! neighbors refuse. An object a Web Service or Tenant Web Service row names refuses with every argument list: BC gives an +//! address with the service name there (GetUrlServiceClientRecord.al:311-317), which is not built. + +use super::y48_platform_probes::outcomes; +use al_test_cli::report::Outcome; + +const SRC: &str = r#" +table 50100 "U Row" { fields { field(1; Id; Integer) { } } keys { key(PK; Id) { Clustered = true; } } } +table 50101 "U Other" { fields { field(1; Id; Integer) { } } keys { key(PK; Id) { Clustered = true; } } } +page 50100 "U List" { PageType = List; SourceTable = "U Row"; layout { area(Content) { repeater(R) { field(IdCtl; Rec.Id) { } } } } } +codeunit 50000 T { Subtype = Test; + [Test] procedure Pinned() var Row: Record "U Row"; begin + if GetUrl(ClientType::ODataV4, CompanyName(), ObjectType::Page, Page::"U List", Row) <> '' then Error('not empty'); end; + [Test] procedure Temporary() var Row: Record "U Row" temporary; begin + if GetUrl(ClientType::ODataV4, CompanyName(), ObjectType::Page, Page::"U List", Row) <> '' then Error('not empty'); end; + [Test] procedure OtherTable() var Row: Record "U Other"; begin + if GetUrl(ClientType::ODataV4, CompanyName(), ObjectType::Page, Page::"U List", Row) <> '' then Error('not empty'); end; + [Test] procedure Report() var Row: Record "U Row"; begin + if GetUrl(ClientType::ODataV4, CompanyName(), ObjectType::Report, 50100, Row) <> '' then Error('not empty'); end; + [Test] procedure PublishedSeedPage() begin + if GetUrl(ClientType::ODataV4, CompanyName(), ObjectType::Page, 42) <> '' then Error('not empty'); end; +} +"#; + +#[test] +fn five_argument_service_forms() { + let o = outcomes(SRC); + let get = |name: &str| { + o.iter() + .find(|(n, _)| n == name) + .unwrap_or_else(|| panic!("{name} in {o:?}")) + .1 + .clone() + }; + assert_eq!(get("Pinned"), Outcome::Pass); + for name in ["Temporary", "OtherTable", "Report"] { + match get(name) { + Outcome::NotRun(why) => assert!(why.contains("this object type or argument list"), "{name}: {why}"), + other => panic!("{name}: {other:?}"), + } + } + match get("PublishedSeedPage") { + Outcome::NotRun(why) => assert!(why.contains("published as a web service"), "{why}"), + other => panic!("PublishedSeedPage: {other:?}"), + } +} diff --git a/crates/al-test-cli/tests/suite/main.rs b/crates/al-test-cli/tests/suite/main.rs index 1a96303cc..2e5a8d935 100644 --- a/crates/al-test-cli/tests/suite/main.rs +++ b/crates/al-test-cli/tests/suite/main.rs @@ -77,6 +77,7 @@ mod find_list_descending; mod fixes2; mod fixpages; mod flowfield_view_find; +mod geturl_service_five_args; mod global_filter_group_page; mod go_to_key_read_up_rows; mod gone_card_modal_close_action; diff --git a/crates/al-vm/src/geturl.rs b/crates/al-vm/src/geturl.rs index d428efaf3..7f8c9787f 100644 --- a/crates/al-vm/src/geturl.rs +++ b/crates/al-vm/src/geturl.rs @@ -299,9 +299,31 @@ impl Session { // (GetUrlObjects.al GetUrl_ObjectIdZero_Record_1); so has a page with a record and UseFilters true, a page without an // id (CY_GetUrl_ServiceClients_UseFilters_And_TypeWithoutId) and an OData table (GetUrl_Object_Types_OtherClients // `odata_table`). + // A Web Service or Tenant Web Service row for the object gives an address with the service name + // (GetUrlServiceClientRecord.al:311-317, ODataV4 and OData of a tenant web service page); that is not built. + let row_type = match object.as_deref() { + Some("Codeunit") => Some(5), + Some("Page") => Some(8), + Some("Query") => Some(9), + _ => None, + }; + if let (Some(ty), Some(n)) = (row_type, id) + && n > 0 + && self.web_service_row_names(ty, n)? + { + return unsupported(format!( + "GetUrl(ClientType::{kind}) of an object published as a web service: the address with its service name is not built" + )); + } let pinned = match (object.as_deref(), id, args.len()) { (Some("Page"), Some(n), 6) if n <= 0 => true, (_, Some(n), _) if n <= 0 => return refuse("an object id that is not positive"), + // A page over the record's table or a codeunit, with a record or a RecordRef that is not temporary, and no + // UseFilters: the empty text for every service type and company (GetUrlServiceClientRecord.al:166-171, + // :176, :186-204 and the three other client types). + (Some("Page") | Some("Codeunit"), _, 5) => { + self.service_record_pinned(object.as_deref(), id, args.get(4))? + } (Some("Page") | Some("Report"), _, 4) => true, (Some("Page"), None, 3) => kind == "SOAP", (Some("Codeunit"), _, 4) => kind == "SOAP" || kind == "ODataV4", @@ -506,6 +528,36 @@ impl Session { /// The `bookmark=` or `filter=` part for a record: the filters when `use_filters` and there are some, nothing when /// `use_filters` and there are none, else the bookmark of the key (GetUrlBookmarkFilter.al:GetUrl_Filter_Text, /// GetUrl_Bookmark_TwoFieldKey `usefilters_true_not_inserted`). + /// Whether the record argument `v` of a five-argument service form is a pinned shape (GetUrlServiceClientRecord.al: + /// 166-182): a Record or an open RecordRef that is not temporary, with a codeunit, or with a page whose source table is + /// the record's table. + fn service_record_pinned( + &mut self, + object: Option<&str>, + id: Option, + v: Option<&Value>, + ) -> Result { + let rec = record_arg(v)?; + let stored = !rec.borrow().temporary; + let table = self.table(&rec)?.object as usize; + if object == Some("Codeunit") { + return Ok(stored); + } + let program = &self.engine.program; + let page = program + .objects + .heads() + .iter() + .position(|o| o.kind == al_ir::ObjKind::Page && id.is_some_and(|n| o.id == Some(n as u32))); + Ok(stored + && page.is_some_and(|p| { + let o = &program.objects[p]; + o.rec_slot.is_some_and( + |s| matches!(o.globals.get(s).map(|g| &g.ty), Some(RtType::Record(t, _)) if *t as usize == table), + ) + })) + } + fn url_record_part(&mut self, rec: &Rec, use_filters: bool) -> Result, Signal> { let t = self.table(rec)?; { diff --git a/crates/al-vm/src/platform/seed.rs b/crates/al-vm/src/platform/seed.rs index cf62c6d1a..5d22737d1 100644 --- a/crates/al-vm/src/platform/seed.rs +++ b/crates/al-vm/src/platform/seed.rs @@ -256,6 +256,47 @@ fn web_service_rows(t: &TableDef, id: u32) -> Vec { } impl Session { + /// Whether a Web Service or Tenant Web Service row names the object of `object_type` (the tables' Object Type ordinal: + /// 5 Codeunit, 8 Page, 9 Query) and `object_id`: the store's rows when the program has the table, else the rows of a + /// fresh tenant above. + pub(crate) fn web_service_row_names( + &self, + object_type: i32, + object_id: i32, + ) -> Result { + let heads = self.engine.program.objects.heads(); + for (table, seed) in [(WEB_SERVICE, WEB_SERVICES), (TENANT_WEB_SERVICE, TENANT_WEB_SERVICES)] { + let loaded = heads + .iter() + .position(|o| o.kind == al_ir::ObjKind::Table && o.id == Some(table)) + .and_then(|oi| self.engine.tables[oi].clone()); + let Some(t) = loaded else { + if seed.iter().any(|&(ty, _, id)| ty == object_type && id == object_id) { + return Ok(true); + } + continue; + }; + let eq = |id: u32, v: Value| al_builtins::filter::FieldFilter { + lang: al_builtins::filter::filter_language(), + field: pos(&t, id), + expr: al_builtins::filter::FilterExpr::Eq(v), + group: 0, + }; + let filters = [ + eq(3, super::option(&t, 3, object_type)), + eq(6, Value::Integer(object_id)), + ]; + let n = self + .store + .count(&self.cx, &t, &filters) + .map_err(|e| al_builtins::native::Signal::unsupported(format!("{e}")))?; + if n > 0 { + return Ok(true); + } + } + Ok(false) + } + /// The seed rows that depend on the program only (All Profile, Web Service, Tenant Web Service), without their /// SystemId, per object index of `tables`. A session clones them instead of building them again. fn program_seed_rows( From 6dd99624d6b04a858bb3bfc23d04a72ecff08949 Mon Sep 17 00:00:00 2001 From: Stefan Maron Date: Tue, 17 Nov 2026 19:25:53 +0100 Subject: [PATCH 6/6] Raise the inconsistency error when a guarded Codeunit.Run ends with a Consistent(false) mark A mark now belongs to the record variable that set it (new module consistent_marks.rs). A guarded Codeunit.Run raises the inconsistency error as it ends when the caller marked one table before the run and the run did not change the marks, also when the run fails with Error or another variable called Consistent(true) before it; or when the inner codeunit set one mark and kept it (errors/ConsistentGuardedRun.al). Other shapes keep the refusal. A Commit after another variable of a marked table called Consistent now refuses; main let it commit, which no test pins. Prunes the 6 Consistent and 5 GetUrl cases on 27, 28 and 29. --- .../tests/suite/consistent_guarded_run.rs | 46 ++++++++ crates/al-test-cli/tests/suite/main.rs | 1 + crates/al-vm/src/consistent_marks.rs | 111 ++++++++++++++++++ crates/al-vm/src/lib.rs | 1 + crates/al-vm/src/recmeta.rs | 6 +- crates/al-vm/src/state.rs | 2 +- crates/al-vm/src/transactions.rs | 39 +++--- docs/codemap.md | 3 +- metrics/27/not-passing.txt | 11 -- metrics/28/not-passing.txt | 11 -- metrics/29/not-passing.txt | 11 -- 11 files changed, 180 insertions(+), 62 deletions(-) create mode 100644 crates/al-test-cli/tests/suite/consistent_guarded_run.rs create mode 100644 crates/al-vm/src/consistent_marks.rs diff --git a/crates/al-test-cli/tests/suite/consistent_guarded_run.rs b/crates/al-test-cli/tests/suite/consistent_guarded_run.rs new file mode 100644 index 000000000..e5ade30cb --- /dev/null +++ b/crates/al-test-cli/tests/suite/consistent_guarded_run.rs @@ -0,0 +1,46 @@ +//! Consistent(false) marks and a guarded Codeunit.Run (al-runner issue 7586 item 4). The pinned shapes raise the +//! inconsistency error as the run ends (errors/ConsistentGuardedRun.al); their neighbors refuse: a Commit after another +//! variable of the table called Consistent(true), an inner codeunit that marks and then fails, two marked tables. + +use super::y48_platform_probes::outcomes; +use al_test_cli::report::Outcome; + +const SRC: &str = r#" +table 50100 "C Row" { fields { field(1; Id; Integer) { } } keys { key(PK; Id) { Clustered = true; } } } +table 50101 "C Other" { fields { field(1; Id; Integer) { } } keys { key(PK; Id) { Clustered = true; } } } +codeunit 50101 "C Nothing" { trigger OnRun() begin end; } +codeunit 50102 "C Mark Fail" { trigger OnRun() var R: Record "C Row"; begin R.Consistent(false); Error('inner failed'); end; } +codeunit 50000 T { Subtype = Test; + [Test] procedure Pinned() var R: Record "C Row"; Ok: Boolean; begin + Commit(); R.Consistent(false); asserterror Ok := Codeunit.Run(Codeunit::"C Nothing"); Error(GetLastErrorCode()); end; + [Test] procedure CommitAfterOther() var M: Record "C Row"; U: Record "C Row"; begin + M.Consistent(false); U.Consistent(true); Commit(); end; + [Test] procedure InnerMarksAndFails() var Ok: Boolean; begin + Commit(); Ok := Codeunit.Run(Codeunit::"C Mark Fail"); end; + [Test] procedure TwoTables() var R: Record "C Row"; O: Record "C Other"; Ok: Boolean; begin + Commit(); R.Consistent(false); O.Consistent(false); asserterror Ok := Codeunit.Run(Codeunit::"C Nothing"); end; +} +"#; + +#[test] +fn guarded_run_with_consistent_marks() { + let o = outcomes(SRC); + let get = |name: &str| { + o.iter() + .find(|(n, _)| n == name) + .unwrap_or_else(|| panic!("{name} in {o:?}")) + .1 + .clone() + }; + assert_eq!(get("Pinned"), Outcome::Fail("DB:TableInConsistent".into())); + match get("CommitAfterOther") { + Outcome::NotRun(why) => assert!(why.contains("another variable"), "{why}"), + other => panic!("CommitAfterOther: {other:?}"), + } + for name in ["InnerMarksAndFails", "TwoTables"] { + match get(name) { + Outcome::NotRun(why) => assert!(why.contains("only Commit() is pinned"), "{name}: {why}"), + other => panic!("{name}: {other:?}"), + } + } +} diff --git a/crates/al-test-cli/tests/suite/main.rs b/crates/al-test-cli/tests/suite/main.rs index 2e5a8d935..d983bbc38 100644 --- a/crates/al-test-cli/tests/suite/main.rs +++ b/crates/al-test-cli/tests/suite/main.rs @@ -36,6 +36,7 @@ mod ci_compile_cache; mod clear_trapping_test_page; mod close_save_error; mod codemap; +mod consistent_guarded_run; mod control_add_in_calls; mod conversions; mod corpus_bump_bot; diff --git a/crates/al-vm/src/consistent_marks.rs b/crates/al-vm/src/consistent_marks.rs new file mode 100644 index 000000000..78a7a753a --- /dev/null +++ b/crates/al-vm/src/consistent_marks.rs @@ -0,0 +1,111 @@ +//! The tables `Record.Consistent(false)` marks in the open transaction, and what ends such a transaction. +//! +//! A mark belongs to the record variable that set it. `Consistent(true)` on that variable lifts it +//! (errors/CuCommitTests.al:393-401, :422-433). `Consistent(true)` on another variable of the table does not: a guarded +//! `Codeunit.Run` after it still raises the inconsistency error (errors/ConsistentGuardedRun.al:272-289). What a Commit +//! does after that is not pinned, nor is any other call on a mark by another variable. + +use crate::Session; +use crate::records::Rec; +use al_builtins::native::Signal; +use al_builtins::value::RecordState; +use std::cell::RefCell; +use std::rc::{Rc, Weak}; + +/// How the variables of a table have called `Consistent` on its mark. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub(crate) enum MarkState { + /// Only the variable that set the mark called `Consistent` on it. + Marked, + /// Another variable of the table called `Consistent(true)` once, the variable that set it nothing since. + ReleasedByAnother, + /// Any other sequence of calls by another variable: not pinned. + Unmeasured, +} + +/// One table `Consistent(false)` marked in the open transaction. +#[derive(Clone, Debug)] +pub(crate) struct ConsistentMark { + /// Object index of the table. + pub(crate) table: u32, + /// The record variable that set the mark (gone when that variable is). + by: Weak>, + pub(crate) state: MarkState, +} + +impl Session { + /// `Record.Consistent(Value)` on `rec`, a database table: marks, lifts or changes the mark of its table for the open + /// transaction (errors/CuCommitTests.al:382-433). A temporary record is not pinned. + pub(crate) fn set_consistent(&mut self, rec: &Rec, consistent: bool) -> Result<(), Signal> { + let (table, temporary) = { + let r = rec.borrow(); + (r.table, r.temporary) + }; + if temporary { + return Err(Signal::Unsupported( + "Consistent on a temporary record (not pinned)".into(), + )); + } + let Some(i) = self.tx.inconsistent.iter().position(|m| m.table == table) else { + if !consistent { + self.tx.inconsistent.push(ConsistentMark { + table, + by: Rc::downgrade(rec), + state: MarkState::Marked, + }); + } + return Ok(()); + }; + let mark = &mut self.tx.inconsistent[i]; + let same = mark.by.upgrade().is_some_and(|b| Rc::ptr_eq(&b, rec)); + match (mark.state, same, consistent) { + (MarkState::Marked, true, true) => { + self.tx.inconsistent.remove(i); + } + (MarkState::Marked, true, false) => {} + (MarkState::Marked, false, true) => mark.state = MarkState::ReleasedByAnother, + _ => mark.state = MarkState::Unmeasured, + } + Ok(()) + } + + /// The marks a guarded `Codeunit.Run` starts with, to compare with the marks it ends with. + pub(crate) fn marks_at_run_start(&self) -> Vec<(u32, MarkState)> { + self.tx.inconsistent.iter().map(|m| (m.table, m.state)).collect() + } + + /// The inconsistency error a guarded `Codeunit.Run` raises as it ends, which the guard does not trap + /// (errors/ConsistentGuardedRun.al). Pinned: one table marked before the run, by the caller (and released or not by + /// another variable before it), and no change to the marks during the run, whether the run succeeds or fails with an + /// `Error` (:170-236, :272-289); or no mark before the run and one the inner codeunit set and kept, when the run + /// succeeds (:238-252). An inner codeunit that lifts its own mark leaves none (:254-270). + /// `None` when no mark is there before or after. Any other shape is refused. + pub(crate) fn guarded_run_end_marks( + &self, + before: &[(u32, MarkState)], + succeeded: bool, + ) -> Result, Signal> { + let after = self.marks_at_run_start(); + if before.is_empty() && after.is_empty() { + return Ok(None); + } + let caller_marked = + before == after.as_slice() && matches!(before, [(_, MarkState::Marked | MarkState::ReleasedByAnother)]); + let inner_marked = before.is_empty() && succeeded && matches!(after.as_slice(), [(_, MarkState::Marked)]); + if caller_marked || inner_marked { + return Ok(Some(self.inconsistent_error(after[0].0 as usize))); + } + self.refuse_inconsistent_end("A guarded Codeunit.Run").map(|()| None) + } + + /// The Commit of a transaction in which another variable of a marked table called `Consistent`: not pinned. + pub(crate) fn refuse_commit_after_other_variable(&self) -> Result<(), Signal> { + match self.tx.inconsistent.first() { + Some(m) if m.state != MarkState::Marked => Err(Signal::unsupported(format!( + "Commit after another variable of table {} called Consistent on its Consistent(false) mark (not pinned)", + self.engine.program.objects[m.table as usize].name + ))), + _ => Ok(()), + } + } +} diff --git a/crates/al-vm/src/lib.rs b/crates/al-vm/src/lib.rs index 7b79e4886..93ef0f2a7 100644 --- a/crates/al-vm/src/lib.rs +++ b/crates/al-vm/src/lib.rs @@ -19,6 +19,7 @@ mod bgsession; mod blob_copy; mod blob_transfer; mod clientless; +mod consistent_marks; mod get_key_value; mod package_data; mod partial_gone; diff --git a/crates/al-vm/src/recmeta.rs b/crates/al-vm/src/recmeta.rs index d8ac70f74..e0f7b123e 100644 --- a/crates/al-vm/src/recmeta.rs +++ b/crates/al-vm/src/recmeta.rs @@ -739,11 +739,7 @@ impl Session { Some(Value::Boolean(b)) => *b, _ => return unsupported("Consistent without a Boolean argument"), }; - let (table, temporary) = { - let r = rec.borrow(); - (r.table, r.temporary) - }; - self.set_consistent(table, temporary, consistent)?; + self.set_consistent(rec, consistent)?; Ok(Value::Null) } RecordOp::ReadConsistency => Ok(Value::Boolean(false)), diff --git a/crates/al-vm/src/state.rs b/crates/al-vm/src/state.rs index 38e6185d8..f6bec16f3 100644 --- a/crates/al-vm/src/state.rs +++ b/crates/al-vm/src/state.rs @@ -99,7 +99,7 @@ pub(crate) struct TxState { /// Modify are not writes of the try (xmlports/shapes-properties/YXmlPortProps.al:861); other writes there are refused. pub(crate) xp_export_try_world: Option, /// The tables (object indexes) `Consistent(false)` marked in the open transaction: `Commit` fails while one is marked. - pub(crate) inconsistent: Vec, + pub(crate) inconsistent: Vec, /// A lock started the open write transaction: `LockTable` on a database table, `ReadIsolation := UpdLock`, or a FindFirst /// under RepeatableRead or UpdLock (codeunits/TestCodeunitRunWriteTransaction.al:211-278). A Commit ends it. pub(crate) lock_tx: bool, diff --git a/crates/al-vm/src/transactions.rs b/crates/al-vm/src/transactions.rs index 297e65594..fedc26d8d 100644 --- a/crates/al-vm/src/transactions.rs +++ b/crates/al-vm/src/transactions.rs @@ -295,8 +295,9 @@ impl Session { self.gate_used_try_write("COMMIT")?; // A table `Consistent(false)` marked fails the Commit (errors/CuCommitTests.al:405-419 // Consistent_False_ThenCommit); `Consistent(true)` lifts the mark (:422-433). - if let Some(&table) = self.tx.inconsistent.first() { - return Err(self.inconsistent_error(table as usize)); + self.refuse_commit_after_other_variable()?; + if let Some(m) = self.tx.inconsistent.first() { + return Err(self.inconsistent_error(m.table as usize)); } // A deferred duplicate-key Insert comes out here (corpus record/TestRecordRuntimeTextsAndViews.al: // Record_Insert_DuplicateKey_WithoutBlobField_IsDeferred_...: "raised by Commit"). @@ -315,7 +316,7 @@ impl Session { /// The error of a Commit while `Consistent(false)` marks `table` (errors/CuCommitTests.al:405-419). The /// table is named in the text; only a table whose caption is its name is pinned. - fn inconsistent_error(&self, table: usize) -> Signal { + pub(crate) fn inconsistent_error(&self, table: usize) -> Signal { let t = &self.engine.program.objects[table]; let caption = t .properties @@ -360,36 +361,21 @@ impl Session { self.tx .inconsistent .first() - .map(|&t| self.engine.program.objects[t as usize].name.clone()) + .map(|m| self.engine.program.objects[m.table as usize].name.clone()) } /// A transaction that ends other than by `Commit()` while `Consistent(false)` marks a table: what BC does is not /// pinned (only `Commit()` is, errors/CuCommitTests.al:405-419), so it is refused. pub(crate) fn refuse_inconsistent_end(&self, how: &str) -> Result<(), Signal> { match self.tx.inconsistent.first() { - Some(&t) => Err(Signal::unsupported(format!( + Some(m) => Err(Signal::unsupported(format!( "{how} ends a transaction while Consistent(false) marks table {} (only Commit() is pinned)", - self.engine.program.objects[t as usize].name + self.engine.program.objects[m.table as usize].name ))), None => Ok(()), } } - /// `Record.Consistent(Value)` on a database table marks or unmarks it for the open transaction - /// (errors/CuCommitTests.al:382-433). A temporary record is not pinned. - pub(crate) fn set_consistent(&mut self, table: u32, temporary: bool, consistent: bool) -> Result<(), Signal> { - if temporary { - return Err(Signal::Unsupported( - "Consistent on a temporary record (not pinned)".into(), - )); - } - self.tx.inconsistent.retain(|&t| t != table); - if !consistent { - self.tx.inconsistent.push(table); - } - Ok(()) - } - /// A TryFunction call whose result is used begins: `consumer` is the frame count of the caller that uses the /// result. What the TryFunctionWrite error names is the caller of that procedure: the test method when a helper /// of it uses the result (errors/CuTryTests.al:105-121 TryInsertThenError_IfNotForm), the test @@ -869,6 +855,7 @@ impl Session { // under TransactionModel::None, and the transaction ends with the run // (codeunits/TestWriteTxTestBoundary.al:Test10_ARunCodeunitMayWriteUnderNone). let began_world = self.tx_model == TxModel::None && self.tx.tx_world == 0; + let marks_before = if guarded { self.marks_at_run_start() } else { Vec::new() }; self.tx.tx_world += 1; if let Some(t) = self.tx.used_tries.last_mut() { t.runs += 1; @@ -900,6 +887,15 @@ impl Session { t.runs -= 1; } self.tx.tx_world -= 1; + // An inner error the pin raises is the one of `Error` (errors/ConsistentGuardedRun.al:100, :221-236). + let pinned_end = result.is_ok() || matches!(&result, Err(Signal::Error(e)) if e.code == "Dialog"); + if guarded && self.pages.bg_worker.is_none() && pinned_end { + if let Some(e) = self.guarded_run_end_marks(&marks_before, result.is_ok())? { + return Err(e); + } + } else if guarded && self.pages.bg_worker.is_none() { + self.refuse_inconsistent_end("A guarded Codeunit.Run")?; + } match result { Ok(_) if guarded => { @@ -929,7 +925,6 @@ impl Session { return Ok(Value::Boolean(false)); } if self.pages.bg_worker.is_none() { - self.refuse_inconsistent_end("A guarded Codeunit.Run")?; self.commit_transaction(); } Ok(Value::Boolean(true)) diff --git a/docs/codemap.md b/docs/codemap.md index 9c99211a3..1d7f7335b 100644 --- a/docs/codemap.md +++ b/docs/codemap.md @@ -426,7 +426,7 @@ al-testkit dev only: compile AL from a string and run a routine al-testf - `filterpage.rs` (268): FilterPageBuilder. Entry: `filter_page_builder_op` 64. - `flowfields.rs` (623): FlowFields (`CalcFormula`), FlowFilters, `CalcFields`, `CalcSums` and `SetAutoCalcFields`. A FlowField's value: `calc_value` (recursion guard by table and field, `CalcStack`), the rows from the store (`tally_stored`) or through the condition FlowFields of source rows (`tally_source_rows`), then one `aggregate` and `finish_value` (the pinned value exceptions). - `group1_sessions.rs` (141): The filters in filter group 1 (the global group) a session holds, and their end with an app's install session (pinned by tests/al-language/install-upgrade/G1sInstallSessionTests.al:55-123 with tests/al-language-xapp-a/G1sXaInstall.al:116-124 and :131-155): what the runner's install sessions set (`Group1InstallShape`) and which filters end. Entry: `Session::note_group1`, `end_group1_install_routine`, `end_group1_install_session`. -- `geturl.rs` (230): `GetUrl` for `ClientType::Web`, Default, Windows, Phone, Tablet, Desktop, Background, Management and NAS with a company, an object, a record bookmark or filters (ADR-042). Entry: `Session::get_url`. +- `geturl.rs` (230): `GetUrl` for `ClientType::Web`, Default, Windows, Phone, Tablet, Desktop, Background, Management, NAS, SOAP, OData, ODataV4 and Api with a company, an object, a record bookmark or filters (ADR-042). Entry: `Session::get_url`. - `globaltriggers.rs` (225): The events of the platform codeunit `Global Triggers` (2000000002, in the platform `System.app`). Entry: `global_setup` 63, `global_enabled` 142, `global_trigger` 157. - `hostvalues.rs` (504): Builtins that answer from the host (ADR-006), and the system field stamps of a write (`stamp_insert`, `stamp_modify`, `stamp_rename`). Entry: `datetime_of_unix_millis` 26, `Replaced` 371. - `assigned_audit.rs`: what a Modify and a Rename write after AL code assigned an audit field (AssignedAuditFields.al, al-runner issue 5207). Three rules, each one allowlist predicate on its measured cell (`modify_keeps_assigned_modified`, `temporary_modify_writes_created_at`, `rename_audit`); every other write keeps the row of `hostvalues.rs`. All three require the variable's own Insert and Get (`al_builtins::value::OwnRead`), followed over every record method by `own_read_before`, `own_read_after` (called from `records::record_op`) and `own_read_after_load`, and ended by any builtin given the variable as an operand but `Clear` (`own_read_end_for_operands`, called from `exec/run.rs`). Facts of a write: `Session::audit_write`, `audit_write_plain`; a RecordRef method is marked by `Session::through_recordref`. @@ -602,6 +602,7 @@ al-testkit dev only: compile AL from a string and run a routine al-testf - `tenant_set_delete.rs` (~300): the Delete or DeleteAll of a stored Tenant Permission Set row with App ID zero deletes the Tenant Permission and Tenant Permission Set Rel. rows that name it, for the shapes the pinned permissions/permission-sets/TenantSetDeleteCascade.al measured (al-runner issue 7854; with Microsoft's apps loaded the delete refuses, `tenant_set_cascade_hooks_off`); other shapes where such rows exist refuse. Called from the Delete arm of `records/op_inner.rs` and `records/delete_all.rs` (plan before the delete, apply after). Entry: `tenant_set_delete_one`, `tenant_set_delete_all`, `tenant_set_cascade_apply`. - `testdata.rs` (420): Test data (ADR-020): `TestBacking` maps a provider's columns onto the compiled table's fields, rebuilds the values and builds the table once per thread. Entry: `TestBacking`, `convert`, `sql_name`. - `transactions.rs` (446): Transactions as AL code sees them. Entry: `TxModel` 15, `CommitBehavior` 27, `codeunit_run` 193. +- `consistent_marks.rs`: the tables `Record.Consistent(false)` marks, per record variable, and the inconsistency error a guarded `Codeunit.Run` raises as it ends. Entry: `Session::set_consistent`, `guarded_run_end_marks`. - `ui.rs` (347): Dialogs raised by the code under test (`Message`, `Confirm`, `StrMenu`) and the test handler functions that answer them. Entry: `UiKind` 18, `UiHandler` 66, `dispatch_ui` 158, `dispatch_ui_returning` 163. - `dev_endpoint_ui.rs`: `--dev-endpoint-ui` (al-runner issue 3697): the answer of the dev-endpoint test runner to a dialog no handler takes, for the shapes measured on BC 28.5 and 29; `pages/dev_endpoint.rs` does the same for `Page.Run(Id)`, `Page.RunModal(Id)` and the request page of `Report.RunModal`. The runner side: `al-testrun` `runtime/session_flags.rs`, `runtime/test_marks.rs` (`TestResult::ui_answered`); `alrunner-cli` `dev_endpoint_ui.rs` (version gate, warnings, JUnit and JSON marks). - `clientless.rs`: what a dialog does in a session without a client (`Session::without_client`): a page background task worker, where the answers are pinned (BjNoGuiDialogs.al, BjNoClientDialogs.al), and the test session under `--no-client` (`Session::no_client_test_session`, `set_clientless_session`), a web-service session as a user measured it on BC 28.4 (al-runner issues 8154, 8158, 8028; assumption `no-client-session`, written probe corpus PR 1420; `no_client_measured` limits its answers to that major, al-version `web_service_session_measured`); what neither covers is refused. `clientless_guard` (called from `exec/run.rs`) answers or refuses the dialog builtins in the worker, `no_client_test_session_guard` in the test session; `no_client_dialog` (called from `ui.rs` with a `NoClientDialog`) sends Confirm, StrMenu, Message, Hyperlink and Notification.Send to the test's handlers and refuses the unmeasured unhandled ones; `no_client_client_type` (from `hostvalues.rs`) answers CurrentClientType in a test method; `clientless_page_guard` (`pages/pageops.rs`) and `clientless_page_ui_guard` (`pages/rows.rs`) Page.Run and RunModal and every TestPage call; `clientless_report` (`reports.rs`, the static runs: CallbackNotAllowed in the worker; in the test session the skipped request page of `measured_skip_report`, the source shape al-sema `reports::bare_processing_report` puts in `ir::Report::bare_processing_only`, and the cells of `measured_report_run`) and `clientless_request_page_guard` the request page of a report; `clientless_xmlport_window_guard` (`xmlports/run_request.rs`). GuiAllowed is in `hostvalues.rs`; the Session and Active Session read refusal in `platform/mod.rs` (`Providers::no_client_session_read`, through `EventStats::no_client_test_session`, kept in step by `sync_no_client_test_session`); `clientless_refuses_test_page_handler` decides which handlers that take a TestPage `ui.rs` `ui_handler` refuses, a bound RequestPageHandler that never ran marks the assumption in `end_ui_scope`; a read of the WorkDate the skipped login code would have set (al-testrun `install::login_work_date`) marks it too. diff --git a/metrics/27/not-passing.txt b/metrics/27/not-passing.txt index 0d158c0aa..3291c5eb3 100644 --- a/metrics/27/not-passing.txt +++ b/metrics/27/not-passing.txt @@ -2418,12 +2418,6 @@ 97427 TPM_Delayed_OpenEdit_NewThenClose_RowInsertedAtClose 97427 TPM_Delayed_OpenEdit_SetValueOnExistingRow_ModifyAtOnce 97435 GetTable_VariantWithAValue_TryFunction -97444 Consistent_FalseOnOneVariable_TrueOnAnother_GuardedRun -97444 Consistent_False_GuardedRun_InnerFails -97444 Consistent_False_GuardedRun_InsertsMarkedTable -97444 Consistent_False_GuardedRun_InsertsOtherTable -97444 Consistent_False_GuardedRun_WritesNothing -97444 GuardedRun_InnerMarksAndInserts 97452 Group1_NextTest_Part1_SetAndLeave 97452 Group1_NextTest_Part2_Read 97452 Group1_OnRecordVariable_RecordRefAndTemporary @@ -2433,11 +2427,6 @@ 97452 Group1_ThroughRecordRef_OtherVariables 97452 OtherGroups_OtherVariable_Count 97452 OtherGroups_OtherVariable_DeleteAll -97455 GetUrl_Api_ObjectAndRecord -97455 GetUrl_ODataV4_FiveArguments_Statement -97455 GetUrl_ODataV4_ObjectAndRecord -97455 GetUrl_OData_ObjectAndRecord -97455 GetUrl_SOAP_ObjectAndRecord 97455 GetUrl_ServiceClients_PagePublishedAsTenantWebService 97466 TPM_FindRecord_Generated_Action_GrowsTheList_WithAndWithoutUpdate 97466 TPM_FindRecord_Generated_GoToKey_InsideAndOutsideTheRange diff --git a/metrics/28/not-passing.txt b/metrics/28/not-passing.txt index 3d484dbac..16a0d698b 100644 --- a/metrics/28/not-passing.txt +++ b/metrics/28/not-passing.txt @@ -2421,12 +2421,6 @@ 97427 TPM_Delayed_OpenEdit_NewThenClose_RowInsertedAtClose 97427 TPM_Delayed_OpenEdit_SetValueOnExistingRow_ModifyAtOnce 97435 GetTable_VariantWithAValue_TryFunction -97444 Consistent_FalseOnOneVariable_TrueOnAnother_GuardedRun -97444 Consistent_False_GuardedRun_InnerFails -97444 Consistent_False_GuardedRun_InsertsMarkedTable -97444 Consistent_False_GuardedRun_InsertsOtherTable -97444 Consistent_False_GuardedRun_WritesNothing -97444 GuardedRun_InnerMarksAndInserts 97452 Group1_NextTest_Part1_SetAndLeave 97452 Group1_NextTest_Part2_Read 97452 Group1_OnRecordVariable_RecordRefAndTemporary @@ -2436,11 +2430,6 @@ 97452 Group1_ThroughRecordRef_OtherVariables 97452 OtherGroups_OtherVariable_Count 97452 OtherGroups_OtherVariable_DeleteAll -97455 GetUrl_Api_ObjectAndRecord -97455 GetUrl_ODataV4_FiveArguments_Statement -97455 GetUrl_ODataV4_ObjectAndRecord -97455 GetUrl_OData_ObjectAndRecord -97455 GetUrl_SOAP_ObjectAndRecord 97455 GetUrl_ServiceClients_PagePublishedAsTenantWebService 97466 TPM_FindRecord_Generated_Action_GrowsTheList_WithAndWithoutUpdate 97466 TPM_FindRecord_Generated_GoToKey_InsideAndOutsideTheRange diff --git a/metrics/29/not-passing.txt b/metrics/29/not-passing.txt index 213b7f4b3..df76c1c20 100644 --- a/metrics/29/not-passing.txt +++ b/metrics/29/not-passing.txt @@ -2465,12 +2465,6 @@ 97427 TPM_Delayed_OpenEdit_NewThenClose_RowInsertedAtClose 97427 TPM_Delayed_OpenEdit_SetValueOnExistingRow_ModifyAtOnce 97435 GetTable_VariantWithAValue_TryFunction -97444 Consistent_FalseOnOneVariable_TrueOnAnother_GuardedRun -97444 Consistent_False_GuardedRun_InnerFails -97444 Consistent_False_GuardedRun_InsertsMarkedTable -97444 Consistent_False_GuardedRun_InsertsOtherTable -97444 Consistent_False_GuardedRun_WritesNothing -97444 GuardedRun_InnerMarksAndInserts 97452 Group1_NextTest_Part1_SetAndLeave 97452 Group1_NextTest_Part2_Read 97452 Group1_OnRecordVariable_RecordRefAndTemporary @@ -2480,11 +2474,6 @@ 97452 Group1_ThroughRecordRef_OtherVariables 97452 OtherGroups_OtherVariable_Count 97452 OtherGroups_OtherVariable_DeleteAll -97455 GetUrl_Api_ObjectAndRecord -97455 GetUrl_ODataV4_FiveArguments_Statement -97455 GetUrl_ODataV4_ObjectAndRecord -97455 GetUrl_OData_ObjectAndRecord -97455 GetUrl_SOAP_ObjectAndRecord 97455 GetUrl_ServiceClients_PagePublishedAsTenantWebService 97466 TPM_FindRecord_Generated_Action_GrowsTheList_WithAndWithoutUpdate 97466 TPM_FindRecord_Generated_GoToKey_InsideAndOutsideTheRange