Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] connector update API to update parameter got illegal_argument_exception when "actions.url" has a reference on parameter #2502

Closed
chishui opened this issue Jun 5, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@chishui
Copy link
Contributor

chishui commented Jun 5, 2024

What is the bug?
I created a connector with payload below

{
    "name": "OpenAI embedding Connector",
    "description": "The connector to public OpenAI model service for GPT 3.5",
    "version": 1,
    "protocol": "http",
    "parameters": {
        "endpoint": "api.openai.com",
        "auth": "API_Key",
        "content_type": "application/json",
        "max_tokens": 7,
        "temperature": 0,
        "model": "text-embedding-ada-002"
    },
    "actions": [
        {
            "action_type": "predict",
            "method": "POST",
            "url": "https://${parameters.endpoint}/v1/embeddings",
            "pre_process_function": "connector.pre_process.openai.embedding",
            "post_process_function": "connector.post_process.openai.embedding",
            "headers": {
                "Authorization": "Bearer ${credential.openAI_key}"
            },
            "request_body": "{ \"model\": \"${parameters.model}\", \"input\": ${parameters.input}}"
        }
    ]
}

Then I call connector update API below to update temperature field in parameters

{	
	"parameters": {
		"temperature": 3
	}
}

I get an exception:

{
	"error": {
		"root_cause": [
			{
				"type": "illegal_argument_exception",
				"reason": "Connector URL is not matching the trusted connector endpoint regex, URL is: https://${parameters.endpoint}/v1/embeddings"
			}
		],
		"type": "illegal_argument_exception",
		"reason": "Connector URL is not matching the trusted connector endpoint regex, URL is: https://${parameters.endpoint}/v1/embeddings"
	},
	"status": 400
}

It worked well if I created the connector with url directly configured not through parameters "url": "https://api.openai.com/v1/embeddings",

I think it fails this validation because the parameters payload in the update API doesn't include endpoint.

How can one reproduce the bug?
Check bug description

What is the expected behavior?
I'm wondering what the expected behavior is when the update API only includes one attribute in parameters, should it overwrite the whole parameters field or it should merge with existing parameters configuration. The current behavior is merge.

If merge is the expected behavior then before making this validation, we may need to merge parameters.

What is your host/environment?

  • OS: MacOS
  • Version: 2.14
  • Plugins: ml-commons

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

@chishui chishui added bug Something isn't working untriaged labels Jun 5, 2024
@dblock
Copy link
Member

dblock commented Jul 1, 2024

[Catch All Triage - Attendees 1, 2, 3, 4, 5]

Thanks for reporting this bug.

@Zhangxunmt
Copy link
Collaborator

Zhangxunmt commented Jul 29, 2024

This is not a bug since the behavior is expected. In the current Update Connector API, the parameters in the update request body will override the existing ones in the connector so some parameters can be deleted. However, I do think we should tune this a bit to merge rather than replacing the whole parameters, as I updated in this #2784.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants