Skip to content

Fix HumanInTheMiddleWrapper.getDummyArgsFor passing null for Project constructor arg#302

Merged
jGauravGupta merged 1 commit into
jeddict:mainfrom
jGauravGupta:npe-in-intractive-mode
Mar 17, 2026
Merged

Fix HumanInTheMiddleWrapper.getDummyArgsFor passing null for Project constructor arg#302
jGauravGupta merged 1 commit into
jeddict:mainfrom
jGauravGupta:npe-in-intractive-mode

Conversation

@jGauravGupta
Copy link
Copy Markdown
Member

In INTERACTIVE mode, JeddictBrain wraps every tool with HumanInTheMiddleWrapper to apply human-in-the-middle approval. ProjectTools and all its subclasses take a Project as their constructor parameter rather than a plain String basedir. getDummyArgsFor() passed null for any non-primitive, non-String parameter, causing ProjectTools(null)basedirOf(null)IllegalArgumentException: project cannot be null.

Changes

HumanInTheMiddleWrapper

  • getDummyArgsFor(Constructor, Object originalTool) — now accepts the original tool and, for non-primitive/non-String parameters, uses reflection to walk the tool's class hierarchy looking for a field whose type satisfies the required parameter type. The field's actual value is used instead of null. Falls back to null if no matching field is found.
  • Added getFieldValueByType(Class, Object) helper — traverses getDeclaredFields + getSuperclass, catches both IllegalAccessException and SecurityException.
// Before: always null for object params → ProjectTools(null) → IAE
} else {
    dummyArgs[i] = null;
}

// After: extract real value from the original tool via reflection
} else {
    dummyArgs[i] = getFieldValueByType(parameterTypes[i], originalTool);
}

…constructor arg

Co-authored-by: jGauravGupta <15934072+jGauravGupta@users.noreply.github.com>
@jGauravGupta jGauravGupta added this to the 3.4.0 milestone Mar 17, 2026
@jGauravGupta jGauravGupta merged commit 7eea5a3 into jeddict:main Mar 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants