Previously, that environment variable was always set in jobs and the lua variable job_desc.num_tasks always had a value in our job submit plugin. After upgrading from 22.05 to 23.02 though both values are undefined unless --ntasks is defined.
This was an intentional change to fix a bug. See: https://bugs.schedmd.com/show_bug.cgi?id=16278#c2 https://github.com/SchedMD/slurm/commit/ef513023ad87a3870bf575efd2329672819c59f0 Unrelated: we have fixed many bugs in 23.02.0 and 23.02.1, including fixing stability issues and fixing an issue that broke mpirun in 23.02. So I encourage you to upgrade to 23.02.2.
Thanks for the info!