[MGNLDAM-902] AssetPreviewProvider throws exception for missing mime type Created: 21/Oct/20 Updated: 30/Aug/21 Resolved: 26/Aug/21 |
|
| Status: | Closed |
| Project: | Magnolia DAM Module |
| Component/s: | DAM App |
| Affects Version/s: | 3.0.3 |
| Fix Version/s: | 3.0.10 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Richard Gange | Assignee: | Milan Divilek |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | VN-Testing, maintenance, metadata, ui-team-support | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Template: |
|
||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||
| Task DoD: |
[X]*
Doc/release notes changes? Comment present?
[X]*
Downstream builds green?
[X]*
Solution information and context easily available?
[X]*
Tests
[X]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||
| Bug DoR: |
[X]*
Steps to reproduce, expected, and actual results filled
[X]*
Affected version filled
|
||||||||||||||||||||
| Release notes required: |
Yes
|
||||||||||||||||||||
| Date of First Response: | |||||||||||||||||||||
| Epic Link: | Migrate Assets | ||||||||||||||||||||
| Sprint: | UI FW 34, UI FW 35 | ||||||||||||||||||||
| Story Points: | 3 | ||||||||||||||||||||
| Description |
|
If an asset is missing its mime type then this will cause an unhandled exception to occur when linking to the asset. It's unclear how someone might end up with this missing metadata but I am reporting the issue in the case we get some more clarity later. See AssetPreviewProvider.java#73. Reproduce
Expected Actual ERROR info.magnolia.admincentral.AdmincentralErrorHandler 14.10.2020 23:56:00 -- AdmincentralUI has encountered an unhandled exception. java.lang.IllegalArgumentException: Could not parse '' at com.google.common.net.MediaType.parse(MediaType.java:1013) ~[guava-28.2-jre.jar:?] at info.magnolia.dam.app.imageprovider.AssetPreviewProvider.lambda$getResource$0(AssetPreviewProvider.java:73) ~[magnolia-dam-app-3.0.3.jar:?] Workaround import info.magnolia.jcr.util.NodeUtil
import org.apache.jackrabbit.commons.predicate.NodeTypePredicate
import javax.jcr.PropertyType
session = ctx.getJCRSession("dam")
children = (NodeUtil.collectAllChildren(session.rootNode,
new NodeTypePredicate("mgnl:asset", true))).iterator()
mimeMappings = ctx.getJCRSession("config").getRootNode().getNode("server").getNode("MIMEMapping")
while (children.hasNext()) {
child = children.next()
if (child.hasNode("jcr:content")) {
contentNode = child.getNode("jcr:content")
if (!contentNode.hasProperty("jcr:mimeType")) {
println "Repairing jcr:mimeType property @ " + contentNode.path
extensionProperty = contentNode.getProperty("extension")
mimeType = (mimeMappings.getNode(extensionProperty.getValue().getString().toLowerCase())).getProperty("mime-type").getString()
contentNode.setProperty("jcr:mimeType", mimeType)
session.save()
}
}
}
Notes |
| Comments |
| Comment by Frank Sommer [ 29/Jan/21 ] |
|
@rgange Why this ticket was closed? I get this error on my project with Magnolia 6.2.3 and DAM 3.0.3. |
| Comment by Richard Gange [ 04/Feb/21 ] |
|
Hello frank.sommer- The reason I closed it is because we are unsure how this happens in the wild. I can artificially recreate the problem but I don't see how admincentral creates the issue. Most likely if you have assets in this state they were created by some other means. OR perhaps they were created a long time ago and have not aged well. In any case, I think the best course of action is to repair the problem assets and give them appropriate mime type metadata. You could use a groovy script for it. HTH |
| Comment by Richard Gange [ 14/Apr/21 ] |
|
First we should do MAGNOLIA-6576. Then we should create a fallback mechanism inside JcrAsset#getMimeType(). By falling back to nothing we hit the parse exception as described in the ticket. If mimeType is empty then try to look up the mime type based on extension. If it cannot be lookup with extensions then the ultimate fallback should be application/octet-stream. |
| Comment by Roman Kovařík [ 13/Aug/21 ] |
|
For release notes: dam link chooser does not crash if mime type of an asset is missing. |