Skip to content

Fix incorrect raising of database_does_not_exist error#4794

Merged
nickva merged 1 commit intomainfrom
fix-database-does-not-exist-error
Oct 4, 2023
Merged

Fix incorrect raising of database_does_not_exist error#4794
nickva merged 1 commit intomainfrom
fix-database-does-not-exist-error

Conversation

@nickva
Copy link
Contributor

@nickva nickva commented Oct 4, 2023

When we're raising the error with the args list [1], the format for the args is a list of arguments not a single arg. So the previous invocations of erlang:error(database_does_not_exist, ?b2l(Id)) would produce a args list of individual database name characters [2].

[1] https://www.erlang.org/doc/man/erlang#error-2

[2] > mem3_shards:opts_for_db(<<"doesnotexit">>).

** exception error: database_does_not_exist
     in function  mem3_shards:opts_for_db/11
        called as mem3_shards:opts_for_db(100,111,101,115,110,111,116,101,120,105,116)

When we're raising the error with the args list [1], the
format for the args is a list of arguments not a single arg. So the previous
invocations of `erlang:error(database_does_not_exist, ?b2l(Id))` would produce
a args list of individual database name characters [2].

[1] https://www.erlang.org/doc/man/erlang#error-2

[2] > mem3_shards:opts_for_db(<<"doesnotexit">>).
```
** exception error: database_does_not_exist
     in function  mem3_shards:opts_for_db/11
        called as mem3_shards:opts_for_db(100,111,101,115,110,111,116,101,120,105,116)
```
@nickva
Copy link
Contributor Author

nickva commented Oct 4, 2023

With the fix it should look like:

(node1@127.0.0.1)1> mem3_shards:opts_for_db(<<"doesnotexist">>).
** exception error: database_does_not_exist
     in function  mem3_shards:opts_for_db/1
        called as mem3_shards:opts_for_db(<<"doesnotexist">>)

Copy link
Contributor

@jaydoane jaydoane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of the 4 changes, seems like only the line in fabric_db_create.erl is covered by tests. Still, it's easy to see by inspection that this is the correct fix (as long as DbName is a binary in all cases), so +1 from me.

@nickva nickva merged commit baa3767 into main Oct 4, 2023
@nickva nickva deleted the fix-database-does-not-exist-error branch October 4, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants