xmidt-org / argus

simple json database abstraction layer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bucket not found error

utsavbatra5 opened this issue · comments

Hi, While posting hook from tr1d1um to argus v0.3.13, we are getting bucket not found error. It works fine on v0.3.11. Can you please advise why it is happening?

@utsavbatra5, was this the latest version of Tr1d1um?

@joe94 Its v0.5.5 for Tr1d1um.

Hi @joe94

The issue is only with inmem DB as of now.

Here is the issue

i.lock.RLock()
defer i.lock.RUnlock()
if _, ok := i.data[key.Bucket]; !ok {
err = store.ErrBucketNotFound

Here we are returning an error (Bucket not found) and here it is not handled.

argus/store/endpoint.go

Lines 80 to 89 in d54494d

setItemRequest := request.(*setItemRequest)
itemResponse, err := s.Get(setItemRequest.key)
if err != nil {
if errors.Is(err, ErrItemNotFound) {
err = s.Push(setItemRequest.key, setItemRequest.item)
if err != nil {
return nil, err
}
return &setItemResponse{}, nil

Fix of this issue will be either remove bucket check from inmem DB or code changes in endpooint.go like below.

	if errors.Is(err, ErrItemNotFound) || errors.Is(err, ErrBucketNotFound) 

Ah, good catch 👍 I don't think the ErrBucketNotFound is a very helpful/actionable error TBH.
I'll remove it and keep the ErrItemNotFound only.

Do you want us to fix this in issue in otel PR which is opened today by Utsav or you will be fixing this in another PR?

I'll fix it in its own PR 👍