Fix Nacos 3.2.1 Prompt Registry integration - #294
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0c98e7e10
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| .configure(PromptTemplate.builder() | ||
| .template(template) | ||
| .variables(model == null ? new HashMap<>() : model)); |
There was a problem hiding this comment.
Render Nacos prompt variables with the right delimiters
When a registry prompt uses Nacos's standard double-brace placeholders like {{name}}, this passes the template unchanged into Spring AI's default PromptTemplate renderer, which expects single-brace placeholders like {name}. In that common Nacos Prompt Registry format, the defaults extracted from PromptVariable do not bind to the remote template, so factory.create(...).render() fails or leaves malformed braces instead of rendering the registry prompt; translate the Nacos placeholders or configure an appropriate renderer before building the PromptTemplate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in db1835f. Registry templates now normalize only declared Nacos double-brace placeholders to the single-brace form expected by the Spring prompt renderer. The initial-load and update tests now use the registry format.
| if (prompt == null) { | ||
| return; |
There was a problem hiding this comment.
Handle Nacos prompt deletion events
When a subscribed prompt is deleted from the Nacos Prompt Registry, the prompt-change event carries a null prompt, but this branch returns without changing templates. In environments that withdraw or delete a prompt after it has been loaded, callers keep rendering the last remote version indefinitely instead of falling back to the local template or removing the entry, so the null event should actively clear or restore the cached state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in db1835f. The factory now retains the first locally created template as a fallback. A null prompt event restores that fallback, or removes the cached entry when no fallback exists. A deletion regression test covers this behavior.
Summary
Tests
mvn -pl auto-configurations/spring-ai-alibaba-autoconfigure-nacos-prompt -am testCloses #246