Skip to content

fix(prompt): preserve global Nacos Config setting - #70

Open
logicwu0 wants to merge 1 commit into
agentic-ai-java:mainfrom
logicwu0:fix/68-nacos-prompt-condition
Open

logicwu0 wants to merge 1 commit into
agentic-ai-java:mainfrom
logicwu0:fix/68-nacos-prompt-condition

Conversation

@logicwu0

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

Disabling Nacos Prompt, including leaving it disabled by default, currently sets the JVM system property spring.nacos.config.enabled to false. This overwrites an explicitly enabled Nacos Config setting and affects other application contexts in the same JVM.

This PR keeps the Prompt condition scoped to its own auto-configuration without changing the application's global Nacos Config setting.

Does this pull request fix one issue?

Fixes #68

Describe how you did it

  • Remove the system-property mutation from PromptTemplateNacosConfigCondition; retain the default-disabled behavior and existing bean backoff conditions.
  • Add regression coverage for all nine combinations of Prompt and global Config settings (true, false, unset), concurrent application contexts, context recreation, and application-provided beans.
  • Restore system properties after each test and serialize access to system properties within the test class.
  • Document the independent switches and migration from the former implicit global disablement.

Describe how to verify it

mvn -B -ntp -pl auto-configurations/prompt/argi-autoconfigure-nacos-prompt -am -Dcheckstyle.skip=false test

Verified locally with JDK 21:

  • Before the production fix, the expanded auto-configuration suite ran 14 tests with 6 failures, reproducing global values changing from true or unset to false.
  • After the fix, all 35 tests across the Prompt and Prompt auto-configuration modules passed with no failures or skips.
  • Checkstyle reported zero violations.

Special notes for reviews

Only three files change: the condition, its auto-configuration tests, and a module README with migration notes.

Applications that depended on disabling Prompt to disable Nacos Config must now explicitly configure spring.nacos.config.enabled=false. Applications using Nacos Config retain responsibility for their connection configuration; disabling Prompt should not suppress genuine Nacos Config errors.

These are offline auto-configuration and unit tests, not a live Nacos-server connectivity verification.

Keep the prompt condition scoped to prompt beans and cover switch combinations, context isolation, and custom beans. Document the migration from the previous global side effect.

Fixes agentic-ai-java#68
@yuluo-yx

Copy link
Copy Markdown
Contributor

I’m not entirely clear on the context here; I’ll need to look into it. As the comment explains, this fixes an issue.

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.

[BUG][P1] 禁用 Nacos Prompt 不应改写 JVM 全局 Nacos Config 开关

2 participants