kazukidb / kazuki

Kazuki: a harmonious data store
Other
5 stars 4 forks source link

Minor/Usability: misleading exception if schema refers to nonexistent property #13

Open mrprescott opened 10 years ago

mrprescott commented 10 years ago

I deleted an attribute from the class I'm storing in a KV store, and forgot to delete it from the schema definition. When I call kvStore.create(), I get the exception shown below.

This is a minor problem, but could be a stumbling block if someone inadvertently typos in a long property name and doesn't see it, and spends time trying to figure out why it's null.

org.skife.jdbi.v2.exceptions.CallbackFailedException: io.kazuki.v0.store.schema.model.TransformException: attribute must not be null: blobId at org.skife.jdbi.v2.DBI.withHandle(DBI.java:276) at org.skife.jdbi.v2.DBI.inTransaction(DBI.java:298) at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:178) at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:152) at org.sonatype.nexus.blobstore.file.kazuki.KazukiBlobMetadataStore.add(KazukiBlobMetadataStore.java:143) at org.sonatype.nexus.blobstore.file.FileBlobStore.create(FileBlobStore.java:84) at org.sonatype.nexus.blobstore.file.FileBlobStoreIT.basicSmokeTest(FileBlobStoreIT.java:91) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: io.kazuki.v0.store.schema.model.TransformException: attribute must not be null: blobId at io.kazuki.v0.internal.v2schema.compact.FieldTransform.pack(FieldTransform.java:72) at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl$3.inTransaction(KeyValueStoreJdbiBaseImpl.java:187) at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl$3.inTransaction(KeyValueStoreJdbiBaseImpl.java:178) at org.skife.jdbi.v2.tweak.transactions.LocalTransactionHandler.inTransaction(LocalTransactionHandler.java:192) at org.skife.jdbi.v2.BasicHandle.inTransaction(BasicHandle.java:306) at org.skife.jdbi.v2.DBI$4.withHandle(DBI.java:301) at org.skife.jdbi.v2.DBI.withHandle(DBI.java:273) ... 36 more

sunnygleason commented 10 years ago

this will be helped by 2 things:

1) I'll fix the error message as you request 2) in the upcoming schema migration release series, we'll be able to detect a schema version mismatch between the app & datastore

mrprescott commented 10 years ago

Nice.

mrprescott commented 10 years ago

I made the same mistake again! But in 0.5.11, this same situation seems to thrown an NPE, obscuring the message completely. The CallbackFailedException (wrapping TransformException) doesn't percolate out, as the error-reporting code NPEs. java.lang.NullPointerException at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:227) at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:163)