Skip to content

[apex] New rule: InvocableClassNoArgConstructor - #6794

Merged
adangel merged 4 commits into
pmd:mainfrom
FishOfPrey:InvocableNoArgConstructor
Jun 23, 2026
Merged

adangel merged 4 commits into
pmd:mainfrom
FishOfPrey:InvocableNoArgConstructor

Conversation

@FishOfPrey

Copy link
Copy Markdown

Detects Apex classes that declare @InvocableVariable fields or properties but define at least one explicit constructor without also providing an accessible no-argument constructor. Salesforce Flow instantiates these classes via a zero-arg constructor; without one, Flow throws a runtime error. Global classes additionally require the no-arg constructor to be global for cross-package Flow access.

Summer '26 Release Note: Provide Visible No-Argument Constructors for Custom Apex Classes Used as Invocable Action Parameters

Describe the PR

Adds a new Apex rule InvocableClassNoArgConstructor in the errorprone category.

Detects Apex classes that declare @InvocableVariable fields or properties but define at least one explicit constructor without also providing an accessible no-argument constructor. Salesforce Flow instantiates these classes via a zero-arg constructor; without one, Flow throws a runtime error. Global classes additionally require the no-arg constructor to be global for cross-package Flow access.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Daniel Ballinger added 2 commits June 20, 2026 07:40
Detects Apex classes that declare @InvocableVariable fields or properties
but define at least one explicit constructor without also providing an
accessible no-argument constructor. Salesforce Flow instantiates these
classes via a zero-arg constructor; without one, Flow throws a runtime
error. Global classes additionally require the no-arg constructor to be
global for cross-package Flow access.
  (between InaccessibleAuraEnabledGetter and MethodWithSameNameAsEnclosingClass)
@pmd-actions-helper

pmd-actions-helper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-06-23 07:50:30+00:00 for d453286)

@adangel adangel changed the title [apex] Add new rule InvocableClassNoArgConstructor [apex] New rule: InvocableClassNoArgConstructor Jun 23, 2026

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

I'll do the small changes myself and merge it afterwards.

@adangel adangel added this to the 7.26.0 milestone Jun 23, 2026
@adangel
adangel merged commit a4b78f5 into pmd:main Jun 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[apex] New Rule: Invocable Classes require a no argument constructor

2 participants