dataverse icon indicating copy to clipboard operation
dataverse copied to clipboard

Strange error response when deleting replaced file via API

Open vera opened this issue 1 year ago • 5 comments

What steps does it take to reproduce the issue?

  1. Create dataset
  2. Upload file
  3. Get and store ID of the uploaded file
  4. Publish dataset
  5. Replace file https://guides.dataverse.org/en/latest/api/native-api.html#replacing-files
  6. Try to delete file using the old file ID (from step 3) https://guides.dataverse.org/en/latest/api/native-api.html#deleting-files
  7. Receive error message: status code 400 + {'status': 'ERROR', 'message': 'Delete failed for file ID 95 (CommandException): Command edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetVersionCommand@263fcde5 failed: Object: null is not a known Entity type.'}
  • To whom does it occur (all users, curators, superusers)?

    API users

  • What did you expect to happen?

    I expected to receive a readable error message telling me why the file cannot be deleted (it has already been published and subsequently replaced)

Which version of Dataverse are you using?

6.1

Any related open or closed issues to this bug report?

not aware of any

Screenshots:

/

vera avatar Mar 25 '24 15:03 vera

@vera interesting. Your steps are clear but to make 100% certain, you are not publishing the dataset, right?

pdurbin avatar Mar 25 '24 17:03 pdurbin

@pdurbin Good catch, yes I did indeed publish the dataset before replacing the file. The error does not occur otherwise. I am sorry for missing that. I have updated the issue text above accordingly.

I have also pushed a failing test here that reproduces the error: https://github.com/vera/dataverse/commit/6e6dd1682851f973f91bfea18285bbe645619576

{
    "status": "ERROR",
    "message": "Delete failed for file ID 30 (CommandException): Command edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetVersionCommand@901e6b6 failed: Object: null is not a known Entity type."
}
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 7.829 s <<< FAILURE! - in edu.harvard.iq.dataverse.api.FilesIT
[ERROR] edu.harvard.iq.dataverse.api.FilesIT.testDeleteReplacedFile  Time elapsed: 5.573 s  <<< FAILURE!
java.lang.AssertionError: 
1 expectation failed.
Expected status code <404> but was <400>.

        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:108)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)
        at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:512)
        at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
        at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:696)
        at io.restassured.internal.ResponseSpecificationImpl.this$2$validateResponseIfRequired(ResponseSpecificationImpl.groovy)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:198)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:62)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
        at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:135)
        at io.restassured.specification.ResponseSpecification$statusCode$0.callCurrent(Unknown Source)
        at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:143)
        at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:89)
        at edu.harvard.iq.dataverse.api.FilesIT.testDeleteReplacedFile(FilesIT.java:2357)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   FilesIT.testDeleteReplacedFile:2357 1 expectation failed.
Expected status code <404> but was <400>.

[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

vera avatar Mar 27 '24 10:03 vera

Thanks for the test!

pdurbin avatar Mar 27 '24 11:03 pdurbin

We should consider a label called " Feature: improve existing feature"

This issue is about improving the message for this error.

sbarbosadataverse avatar Jun 26 '24 16:06 sbarbosadataverse

We should consider a label called " Feature: improve existing feature"

Or maybe to keep it shorter Type: Improvement

DS-INRAE avatar Jun 27 '24 08:06 DS-INRAE

No objection but I'd say this issue is correctly labeled as a bug. 😄

pdurbin avatar Jul 08 '24 18:07 pdurbin