Skip to content

Skyflow batch delete operation fails and returns empty skyflow_id list #184

@ghevge

Description

@ghevge

I am trying to do a batch delete operation using the Groovy code below:
It works for the majority of cases, but I have a scenario where Skyflow returns the error:

Error: {"error":{"grpc_code":5,"http_code":404,"message":"Delete failed. skyflow_id [] is invalid. Specify a valid Skyflow ID.","http_status":"Not Found","details":[]}}

Why is Skyflow returning an empty array of problematic ids when all the ids I'm passing are non-empty?

This is a blocker for me as I am not able to delete in batches because of these errors.

 protected deleteRecords(String tableName, JSONObject payload) {
        String skyflowUrl = configuration.getVaultURL() + '/v1/vaults/' + configuration.getVaultID() + '/' + tableName

        def delete = new HttpDeleteBody(skyflowUrl)

        delete.setHeader('Authorization', "Bearer ${tokenUtils.getBearerToken(configuration.getTokenProvider())}")
        delete.setHeader(Constants.SDK_METRICS_HEADER_KEY, Helpers.getMetrics().toJSONString())
        delete.setHeader('Content-Type', ContentType.APPLICATION_JSON.getMimeType())
        String payloadString = payload.toString()
        delete.setEntity(new StringEntity(payloadString, ContentType.APPLICATION_JSON))

        HttpResponseInterceptor responseLoggingInterceptor = { HttpResponse response, HttpContext context ->
            if (response.getStatusLine().getStatusCode() in REST_RETRY_ERRORS) {
                log.warn('Retry it...')
                Thread.sleep(REST_RETRY_INTERVAL_MS)
                def errorMessage = response.getEntity().getContent().text
                throw new IOException("Error: ${errorMessage}")
            }
        }

        def client = HttpClients.custom()
                .addInterceptorLast(responseLoggingInterceptor)
                .build()

        try {
            def response = client.execute(delete)
            def responseBody = EntityUtils.toString(response.entity)
            return new JsonSlurper().parseText(responseBody) as Map
        } finally {
            client.close()
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions