ml-commons icon indicating copy to clipboard operation
ml-commons copied to clipboard

[BUG] Created Time and Last Updated Time are not implemented on Connector

Open dbwiddis opened this issue 1 year ago • 1 comments

What is the bug?

The .plugin-ml-connector index contains field mappings for created_time and last_updated_time but these are never populated.

How can one reproduce the bug? Steps to reproduce the behavior:

  1. Create a connector.
  2. Inspect the created document using the REST API
  3. Observe there are no created_time or last_updated_time fields.

What is the expected behavior?

  • the created and last updated time are both populated with the same Instant.now() upon instantiation, or at least set before index request
  • the last updated time is updated before an update request

What is your host/environment?

OpenSearch :)

Do you have any screenshots?

http://localhost:9200/.plugins-ml-connector/_doc/44ymvpEBPIzofVXwNZHj
{
    "_index": ".plugins-ml-connector",
    "_id": "44ymvpEBPIzofVXwNZHj",
    "_version": 1,
    "_seq_no": 0,
    "_primary_term": 1,
    "found": true,
    "_source": {
        "name": "Cohere Chat Model",
        "version": "1",
        "description": "The connector to Cohere's public chat API",
        "protocol": "http",
        "parameters": {
            "model": "command"
        },
        "credential": {
            "cohere_key": "REDACTED"
        },
        "actions": [
            {
                "action_type": "PREDICT",
                "method": "POST",
                "url": "https://api.cohere.ai/v1/chat",
                "headers": {
                    "Authorization": "Bearer ${credential.cohere_key}",
                    "Request-Source": "unspecified:opensearch"
                },
                "request_body": "{ \"message\": \"${parameters.inputs}\", \"model\": \"${parameters.model}\" }"
            }
        ]
    }
}

Do you have any additional context?

The HttpConnector class has fields for createdTime and lastUpdatedTime which are properly parsed from incoming transport or XContent, and properly sent to outgoing transport or XContent unless null. The problem is that they are always null.

  • there are no setters for them
  • they are never given any values

Suggested fix(es):

  • in the AbstractConnector, assign them a value on instantiating. (Use the same value for both.)
  • Add a setter for the updated time
  • Set the updated time when using the UpdateConnector API.

dbwiddis avatar Sep 04 '24 21:09 dbwiddis

Can I get assigned this bug?

brianf-aws avatar Sep 06 '24 20:09 brianf-aws