Andrea Cosentino created CAMEL-24608:
----------------------------------------

             Summary: camel-langchain4j-agent-api: LanguageGuardrail 
minLanguageRatio option is never applied
                 Key: CAMEL-24608
                 URL: https://issues.apache.org/jira/browse/CAMEL-24608
             Project: Camel
          Issue Type: Bug
          Components: camel-langchain4j-agent
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.23.0


LanguageGuardrail declares minLanguageRatio, sets it from the constructor and 
the public builder method minLanguageRatio(double), and stores it on the 
instance, but validate() never reads it (and there is no getter). A user who 
builds 
LanguageGuardrail.builder().allowedLanguages(ENGLISH).minLanguageRatio(0.8) 
expects at least 80% of the characters to be in an allowed language; the ratio 
is silently ignored, so text that is mostly a foreign script with a single 
allowed-language character still passes. The advertised option does nothing.

Fix: enforce the ratio in validate() (compute the allowed-language character 
fraction and fail when it is below minLanguageRatio), or remove the option.

_Reported by an automated functional audit._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to