Skip to content

fix #335: stop logging expected AI prompt responses as errors - #336

Open
hdimer wants to merge 1 commit into
nacos-group:masterfrom
hdimer:fix/335-ai-grpc-expected-response-logging
Open

fix #335: stop logging expected AI prompt responses as errors#336
hdimer wants to merge 1 commit into
nacos-group:masterfrom
hdimer:fix/335-ai-grpc-expected-response-logging

Conversation

@hdimer

@hdimer hdimer commented Aug 29, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug fix
  • New feature
  • Enhancement
  • Refactoring
  • Documentation
  • CI/CD
  • Other

What does this PR do?

AIGRPCClientProxy.request_ai_server logged every NacosException at ERROR
level, so a plain 304 / prompt data is up to date cache-validation response
produced an ERROR line on every prompt poll, even though
PromptCacheHolder._update_prompt_loop already treats NOT_MODIFIED as the
expected outcome and ignores it.

The HTTP AI proxy already has an idiom for this: _req_api and _req_api_bytes
in ai_http_client_proxy.py re-raise NOT_MODIFIED and NOT_FOUND without
logging. This applies the same two lines to the gRPC proxy so both transports
behave the same way. Every other error code still logs at ERROR exactly as
before.

One consequence worth confirming: subscribe_prompt swallows NOT_FOUND
without logging, so subscribing to a prompt that does not exist is now silent
over gRPC. That is already the behaviour on the HTTP transport, so this brings
the two into line, but say the word if you would rather I limit the change to
NOT_MODIFIED only.

Which issue(s) does this PR fix?

Fixes #335

How has this been tested?

New test/test_ai_grpc_client_proxy.py covers three cases: a 304 and a 404
response emit no ERROR record and still raise, and a 500 response still logs one
ERROR. The two 304/404 tests fail on master and pass with this change. The 500
test passes either way and is there to rule out the lazier fix of demoting the
whole logger.error call.

Ran locally: ruff check --select F --ignore F401 --exclude "*/grpcauto/*" v2/,
the import v2.nacos smoke check, and the offline tests under test/ (45 tests,
all passing). The tests that need a live Nacos server were not run.

I used an AI assistant while working on this. The reasoning, the tests and the
final code are mine and I have reviewed every line.

Checklist

  • Unit tests added/updated
  • Documentation updated (if needed)
  • No breaking changes (or described above)

Used AI assistance on this; I reviewed and tested the change myself.

The gRPC AI proxy logged every NacosException at ERROR level, so a normal
304 (prompt data is up to date) cache-validation response produced an
ERROR line on every prompt poll. The HTTP AI proxy already re-raises
NOT_MODIFIED and NOT_FOUND without logging; follow the same idiom here.
Other error codes still log at ERROR as before.
@CLAassistant

CLAassistant commented Aug 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hdimer
hdimer marked this pull request as ready for review August 29, 2026 15:48
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] Expected prompt 304 responses are logged as ERROR by the AI gRPC proxy

2 participants