Skip to content

fix(whelk-core): don't set null type in in retainLinks; don't accept null type in isTypedNode - #1840

Merged
andersju merged 1 commit into
developfrom
fix/dont-set-or-accept-null-type
Sep 23, 2026
Merged

andersju merged 1 commit into
developfrom
fix/dont-set-or-accept-null-type

Conversation

@andersju

Copy link
Copy Markdown
Member

We've seen a lot of this:

2026-09-22 16:28:20,289 [qtp1668016508-410] WARN  whelk.util.FresnelUtil - Error computing label for [{extent=[{@type=Extent, label=[330 s.], computedLabel=330 s.}], @type=PhysicalResource, physicalDetailsNote=ill., responsibilityStatement=Fritz von Dardel, _categoryByCollection={@none=[{inScheme={@id=https://id.kb.se/term/saobf}, @type=CarrierForm, meta={mainEntity={@id=https://id.kb.se/term/saobf/Print}, @type=Record, @id=https://libris.kb.se/jq0mh5c5l2ff7sc2, computedLabel=https://libris.kb.se/jq0mh5c5l2ff7sc2}, @id=https://id.kb.se/term/saobf/Print, prefLabelByLang={sv=Tryck, en=Print}, computedLabel=Tryck · Bärarform · https://id.kb.se/term/saobf}, {code=nc, inScheme={@id=https://id.kb.se/term/rda}, @type=CarrierType, meta={mainEntity={@id=https://id.kb.se/term/rda/Volume}, @type=Record, @id=https://libris.kb.se/bq2n963md2b6xhs1, computedLabel=https://libris.kb.se/bq2n963md2b6xhs1}, searchLabelByLang={sv=Bok, en=Book}, inCollection={@id=https://id.kb.se/term/div/select}, @id=https://id.kb.se/term/rda/Volume, prefLabelByLang={sv=Volym, en=Volume}, sameAs=[{@id=https://id.kb.se/term/rda/carrier/nc}, {@id=https://id.kb.se/term/rda/carrier/volume}], labelByLang={sv=Volym, en=Volume}, computedLabel=Volym · Bärartyp · https://id.kb.se/term/rda}], @type=null}, reverseLinks={totalItemsByRelation={itemOf=23, itemOf.instanceOf=0, reproductionOf=1}, totalItems=24, @type=PartialCollectionView, @id=https://libris.kb.se/find?o=https%3A%2F%2Flibris.kb.se%2Fbtm6cqzn1trdhkm%23it, computedLabel=https://libris.kb.se/find?o=https%3A%2F%2Flibris.kb.se%2Fbtm6cqzn1trdhkm%23it}, __responsibilityStatement=[Fritz von Dardel], instanceOf={contribution=[{agent={lifeSpan=1817-1901, @type=Person, meta={mainEntity={@id=https://libris.kb.se/khwzzvw34n17nl7#it}, @type=Record, @id=https://libris.kb.se/khwzzvw34n17nl7, computedLabel=https://libris.kb.se/khwzzvw34n17nl7}, familyName=Dardel, givenName=Fritz von, @id=https://libris.kb.se/khwzzvw34n17nl7#it, hasVariant=[{lifeSpan=1817-1901, @type=Person, familyName=Dardel, givenName=Fritz Ludvig von, computedLabel=Dardel, Fritz Ludvig von, 1817-1901}, {lifeSpan=1817-1901, @type=Person, familyName=von Dardel, givenName=Ludvig, computedLabel=von Dardel, Ludvig, 1817-1901}, {lifeSpan=1817-1901, @type=Person, name=Stift, marc:titlesAndOtherWordsAssociatedWithAName=[pseud. för Fritz von Dardel], computedLabel=Stift, 1817-1901, pseud. för Fritz von Dardel}], sameAs=[{@id=http://libris.kb.se/resource/auth/183423}], computedLabel=Dardel, Fritz von, 1817-1901}, role={code=aut, @type=Role, meta={mainEntity={@id=https://id.kb.se/relator/author}, @type=Record, @id=https://libris.kb.se/01671gl323zxzzhh, computedLabel=https://libris.kb.se/01671gl323zxzzhh}, @id=https://id.kb.se/relator/author, prefLabelByLang={sv=Författare, en=Author}, sameAs=[{@id=https://id.kb.se/relator/aut}], computedLabel=Författare}, @type=PrimaryContribution, computedLabel=Dardel, Fritz von, 1817-1901 (Författare)}], @type=Monograph, subject=[{lifeSpan=1817-1901, @type=Person, meta={mainEntity={@id=https://libris.kb.se/khwzzvw34n17nl7#it}, @type=Record, @id=https://libris.kb.se/khwzzvw34n17nl7, computedLabel=https://libris.kb.se/khwzzvw34n17nl7}, familyName=Dardel, givenName=Fritz von, @id=https://libris.kb.se/khwzzvw34n17nl7#it, hasVariant=[{lifeSpan=1817-1901, @type=Person, familyName=Dardel, givenName=Fritz Ludvig von, computedLabel=Dardel, Fritz Ludvig von, 1817-1901}, {lifeSpan=1817-1901, @type=Person, familyName=von Dardel, givenName=Ludvig, computedLabel=von Dardel, Ludvig, 1817-1901}, {lifeSpan=1817-1901, @type=Person, name=Stift, marc:titlesAndOtherWordsAssociatedWithAName=[pseud. för Fritz von Dardel], computedLabel=Stift, 1817-1901, pseud. för Fritz von Dardel}], sameAs=[{@id=http://libris.kb.se/resource/auth/183423}], computedLabel=Dardel, Fritz von, 1817-1901}], language=[{code=swe, @type=Language, meta={mainEntity={@id=https://id.kb.se/language/swe}, @type=Record, @id=https://libris.kb.se/93lzl5lfc2l3hvc7, computedLabel=https://libris.kb.se/93lzl5lfc2l3hvc7}, @id=https://id.kb.se/language/swe, prefLabelByLang={sv=Svenska, en=Swedish}, sameAs=[{@id=https://id.kb.se/i18n/lang/sv}], computedLabel=Svenska}], _categoryByCollection={@none=[{@type=GenreForm, meta={mainEntity={@id=https://id.kb.se/term/ktg/NonFictionLiterature}, @type=Record, @id=https://libris.kb.se/wjfqxkqjz3vsssck}, @id=https://id.kb.se/term/ktg/NonFictionLiterature, prefLabelByLang={sv=Ej skönlitteratur, en=Non-fiction literature}}, {code=txt, inScheme={@id=https://id.kb.se/term/rda}, @type=ContentType, meta={mainEntity={@id=https://id.kb.se/term/rda/Text}, @type=Record, @id=https://libris.kb.se/pnpsnkg0r5b6x092}, @id=https://id.kb.se/term/rda/Text, prefLabelByLang={sv=Text, en=Text}, sameAs=[{@id=https://id.kb.se/term/rda/content/text}, {@id=https://id.kb.se/term/rda/content/txt}]}], @type=null}, category=[{@type=GenreForm, meta={mainEntity={@id=https://id.kb.se/term/ktg/NonFictionLiterature}, @type=Record, @id=https://libris.kb.se/wjfqxkqjz3vsssck}, @id=https://id.kb.se/term/ktg/NonFictionLiterature, prefLabelByLang={sv=Ej skönlitteratur, en=Non-fiction literature}}, {code=txt, inScheme={@id=https://id.kb.se/term/rda}, @type=ContentType, meta={mainEntity={@id=https://id.kb.se/term/rda/Text}, @type=Record, @id=https://libris.kb.se/pnpsnkg0r5b6x092}, @id=https://id.kb.se/term/rda/Text, prefLabelByLang={sv=Text, en=Text}, sameAs=[{@id=https://id.kb.se/term/rda/content/text}, {@id=https://id.kb.se/term/rda/content/txt}]}], classification=[{code=Ibz Dardel, Fritz von, inScheme={code=kssb, @type=ConceptScheme, version=6, sameAs=[{@id=https://id.kb.se/term/kssb%2F6/}]}, @type=Classification, _sab=Ibz Dardel, Fritz von}], computedLabel=Svenska · Dardel, Fritz von, 1817-1901}, meta={descriptionCreator={@type=Library, meta={mainEntity={@id=https://libris.kb.se/library/Li}, @type=Record, @id=https://libris.kb.se/000n6qq3157gh22z}, name=Linköpings universitetsbibliotek, @id=https://libris.kb.se/library/Li, sigel=Li, sameAs=[{@id=http://bibdb.libris.kb.se/library/Li}]}, mainEntity={@id=https://libris.kb.se/btm6cqzn1trdhkm#it}, marc:catalogingSource={@id=https://id.kb.se/marc/CooperativeCatalogingProgram}, encodingLevel=marc:AbbreviatedLevel, @type=Record, created=2001-12-11T00:00:00+01:00, generationDate=2026-06-03T10:16:21.793+02:00, descriptionConventions=[{code=a, inScheme={@id=https://id.kb.se/marc}, @type=marc:CatFormType, meta={mainEntity={@id=https://id.kb.se/marc/Aacr2}, @type=Record, @id=https://libris.kb.se/v9b707fzx4wqz50j}, @id=https://id.kb.se/marc/Aacr2, prefLabelByLang={sv=AACR2/KRS, en=AACR 2}, sameAs=[{@id=https://id.kb.se/marc/CatFormType-a}]}], recordStatus=marc:CorrectedOrRevised, modified=2019-10-10T09:11:51.497+02:00, @id=https://libris.kb.se/btm6cqzn1trdhkm, descriptionLastModifier={@type=Library, meta={mainEntity={@id=https://libris.kb.se/library/S}, @type=Record, @id=https://libris.kb.se/000n6qq313f988g2}, name=Kungliga biblioteket, @id=https://libris.kb.se/library/S, sigel=S, sameAs=[{@id=http://bibdb.libris.kb.se/library/S}]}, librissearch:controlNumbers=[29090, btm6cqzn1trdhkm], identifiedBy=[{@type=LibrisIIINumber, value=9900264681}], controlNumber=29090, generationProcess={@id=https://libris.kb.se/sys/globalchanges/cleanups/2026/05/fmt-548/fmt-548-replace-local-otherPhysicalFormat-with-linked-reproductionOf.groovy}, sameAs=[{@id=http://libris.kb.se/bib/29090}]}, publication=[{country={code=sw, @type=Country, meta={mainEntity={@id=https://id.kb.se/country/sw}, @type=Record, @id=https://libris.kb.se/jf9xxz4ml0jrz74j}, @id=https://id.kb.se/country/sw, prefLabelByLang={sv=Sverige, en=Sweden}}, agent={@type=Agent, label=[Norstedt]}, year=1931, @type=PrimaryPublication, librissearch:year=1931, place=[{@type=Place, label=[Stockholm]}]}], @id=https://libris.kb.se/btm6cqzn1trdhkm#it, hasTitle=[{@type=Title, mainTitle=Minnen från senare år, 1888-1898}], @reverse={itemOf=[{heldBy={@id=https://libris.kb.se/library/Bo, isPartOf={@id=https://libris.kb.se/library/org/Bo1}}, @type=Item, @id=https://libris.kb.se/bgn9pmkh53zlnbp#it}, {heldBy={@id=https://libris.kb.se/library/Ra, isPartOf={@id=https://libris.kb.se/library/org/RA}}, @type=Item, @id=https://libris.kb.se/bgmwgnph0nblnxq#it}, {heldBy={@id=https://libris.kb.se/library/F, isPartOf={@id=https://libris.kb.se/library/org/F}}, @type=Item, @id=https://libris.kb.se/26ddccr71fdnt4l#it}, {heldBy={@id=https://libris.kb.se/library/U, isPartOf={@id=https://libris.kb.se/library/org/UUB}}, @type=Item, @id=https://libris.kb.se/fkq0krsl28vwsck#it}, {heldBy={@id=https://libris.kb.se/library/Olm, isPartOf={@id=https://libris.kb.se/library/org/OLM}}, @type=Item, @id=https://libris.kb.se/8dlnhdsf2gswzc9#it}, {heldBy={@id=https://libris.kb.se/library/L, isPartOf={@id=https://libris.kb.se/library/org/LUB}}, @type=Item, @id=https://libris.kb.se/6bhrbjkc0l0c811#it}, {heldBy={@id=https://libris.kb.se/library/G, isPartOf={@id=https://libris.kb.se/library/org/GUB}}, @type=Item, @id=https://libris.kb.se/37dn7fg82srvbzn#it}, {heldBy={@id=https://libris.kb.se/library/Lin2, isPartOf={@id=https://libris.kb.se/library/org/GOTA}}, @type=Item, @id=https://libris.kb.se/z39m9cs426jz66v#it}, {heldBy={@id=https://libris.kb.se/library/Uh, isPartOf={@id=https://libris.kb.se/library/org/UUB}}, @type=Item, @id=https://libris.kb.se/qv20kvfw31bdvkj#it}, {heldBy={@id=https://libris.kb.se/library/Umdp, isPartOf={@id=https://libris.kb.se/library/org/UM}}, @type=Item, @id=https://libris.kb.se/glr1lstm0gbv1dt#it}, {heldBy={@id=https://libris.kb.se/library/Alb, isPartOf={@id=https://libris.kb.se/library/org/ALB}}, @type=Item, @id=https://libris.kb.se/0ks1vsfpxqrq80vp#it}, {heldBy={@id=https://libris.kb.se/library/Am, isPartOf={@id=https://libris.kb.se/library/org/AM}}, @type=Item, @id=https://libris.kb.se/049k4bc5030lv07#it}, {heldBy={@id=https://libris.kb.se/library/Sa, isPartOf={@id=https://libris.kb.se/library/org/SA}}, @type=Item, @id=https://libris.kb.se/kpvkx3mq424cgq2#it}, {heldBy={@id=https://libris.kb.se/library/LnuV, isPartOf={@id=https://libris.kb.se/library/org/LNU}}, @type=Item, @id=https://libris.kb.se/48f4twr92fc2jgl#it}, {heldBy={@id=https://libris.kb.se/library/Tida, isPartOf={@id=https://libris.kb.se/library/org/Tida}}, @type=Item, @id=https://libris.kb.se/k3pgk7xnh8rdmdn6#it}, {heldBy={@id=https://libris.kb.se/library/E, isPartOf={@id=https://libris.kb.se/library/org/E}}, @type=Item, @id=https://libris.kb.se/26cm6df75ctn4zf#it}, {heldBy={@id=https://libris.kb.se/library/Q, isPartOf={@id=https://libris.kb.se/library/org/UmUB}}, @type=Item, @id=https://libris.kb.se/9flvfmng2fhkdgd#it}, {heldBy={@id=https://libris.kb.se/library/S, isPartOf={@id=https://libris.kb.se/library/org/KB}}, @type=Item, @id=https://libris.kb.se/chnxhpqj31f98rb#it}, {heldBy={@id=https://libris.kb.se/library/Stsm, isPartOf={@id=https://libris.kb.se/library/org/STSM}}, @type=Item, @id=https://libris.kb.se/djpfgp2k4f0f3jv#it}, {heldBy={@id=https://libris.kb.se/library/H, isPartOf={@id=https://libris.kb.se/library/org/SUB}}, @type=Item, @id=https://libris.kb.se/48fp8gh909jld72#it}, {heldBy={@id=https://libris.kb.se/library/Kra, isPartOf={@id=https://libris.kb.se/library/org/RA}}, @type=Item, @id=https://libris.kb.se/59gq9hjb2h93nrr#it}, {heldBy={@id=https://libris.kb.se/library/Olmb, isPartOf={@id=https://libris.kb.se/library/org/OLMB}}, @type=Item, @id=https://libris.kb.se/bgnmdf6h3n02wbv#it}, {heldBy={@id=https://libris.kb.se/library/Ajtt, isPartOf={@id=https://libris.kb.se/library/org/AJTT}}, @type=Item, @id=https://libris.kb.se/z38j39b42mn8p85#it}], reproductionOf=[{production=[{date=2019, typeNote=Digitalt faksimil, agent={@id=https://libris.kb.se/20dgd3zl56pmrzk#it}, @type=Reproduction, place=[{@type=Place, label=Stockholm}]}], @type=DigitalResource, meta={mainEntity={@id=https://libris.kb.se/mxc42r54k1b45wp8#it}, @type=Record, @id=https://libris.kb.se/mxc42r54k1b45wp8}, publication=[{country={code=sw, @type=Country, meta={mainEntity={@id=https://id.kb.se/country/sw}, @type=Record, @id=https://libris.kb.se/jf9xxz4ml0jrz74j}, @id=https://id.kb.se/country/sw, prefLabelByLang={sv=Sverige, en=Sweden}}, agent={@type=Agent, label=[Norstedt]}, year=1931, @type=PrimaryPublication, place=[{@type=Place, label=[Stockholm]}]}], @id=https://libris.kb.se/mxc42r54k1b45wp8#it, hasTitle=[{@type=Title, mainTitle=Minnen från senare år, 1888-1898}], identifiedBy=[{@type=Identifier, value=kb-digitization-001202828,1}], instanceOf={contribution=[{agent={lifeSpan=1817-1901, @type=Person, meta={mainEntity={@id=https://libris.kb.se/khwzzvw34n17nl7#it}, @type=Record, @id=https://libris.kb.se/khwzzvw34n17nl7}, familyName=Dardel, givenName=Fritz von, @id=https://libris.kb.se/khwzzvw34n17nl7#it, hasVariant=[{lifeSpan=1817-1901, @type=Person, familyName=Dardel, givenName=Fritz Ludvig von}, {lifeSpan=1817-1901, @type=Person, familyName=von Dardel, givenName=Ludvig}, {lifeSpan=1817-1901, @type=Person, name=Stift, marc:titlesAndOtherWordsAssociatedWithAName=[pseud. för Fritz von Dardel]}], sameAs=[{@id=http://libris.kb.se/resource/auth/183423}]}, role={code=aut, @type=Role, meta={mainEntity={@id=https://id.kb.se/relator/author}, @type=Record, @id=https://libris.kb.se/01671gl323zxzzhh}, @id=https://id.kb.se/relator/author, prefLabelByLang={sv=Författare, en=Author}, sameAs=[{@id=https://id.kb.se/relator/aut}]}, @type=PrimaryContribution}], @type=Monograph, language=[{code=swe, @type=Language, meta={mainEntity={@id=https://id.kb.se/language/swe}, @type=Record, @id=https://libris.kb.se/93lzl5lfc2l3hvc7}, @id=https://id.kb.se/language/swe, prefLabelByLang={sv=Svenska, en=Swedish}, sameAs=[{@id=https://id.kb.se/i18n/lang/sv}]}]}}]}, category=[{inScheme={@id=https://id.kb.se/term/saobf}, @type=CarrierForm, meta={mainEntity={@id=https://id.kb.se/term/saobf/Print}, @type=Record, @id=https://libris.kb.se/jq0mh5c5l2ff7sc2}, @id=https://id.kb.se/term/saobf/Print, prefLabelByLang={sv=Tryck, en=Print}}, {code=nc, inScheme={@id=https://id.kb.se/term/rda}, @type=CarrierType, meta={mainEntity={@id=https://id.kb.se/term/rda/Volume}, @type=Record, @id=https://libris.kb.se/bq2n963md2b6xhs1}, searchLabelByLang={sv=Bok, en=Book}, inCollection={@id=https://id.kb.se/term/div/select}, @id=https://id.kb.se/term/rda/Volume, prefLabelByLang={sv=Volym, en=Volume}, sameAs=[{@id=https://id.kb.se/term/rda/carrier/nc}, {@id=https://id.kb.se/term/rda/carrier/volume}], labelByLang={sv=Volym, en=Volume}}], sameAs=[{@id=http://libris.kb.se/resource/bib/29090}], computedLabel=Minnen från senare år, 1888-1898 · Norstedt, 1931}]: java.lang.RuntimeException: Expected type/types, found null
java.lang.RuntimeException: Expected type/types, found null
  at whelk.util.FresnelUtil.firstType(FresnelUtil.java:1533)
  at whelk.util.FresnelUtil.isStructuredValue(FresnelUtil.java:1475)
  at whelk.util.FresnelUtil.scriptAlternatives(FresnelUtil.java:1457)
  at whelk.util.FresnelUtil.applyLens(FresnelUtil.java:373)
  at whelk.util.FresnelUtil.applyLens(FresnelUtil.java:357)
  at whelk.util.FresnelUtil.applyLens(FresnelUtil.java:348)
  at whelk.util.FresnelUtil.asFormattedString(FresnelUtil.java:188)
  at whelk.util.FresnelUtil.lambda$insertComputedLabels$0(FresnelUtil.java:237)
  at whelk.util.DFS.node(DFS.java:32)
  at whelk.util.DFS.descend(DFS.java:55)
  at whelk.util.DFS.node(DFS.java:42)
  at whelk.util.DFS.descend(DFS.java:55)
  at whelk.util.DFS.node(DFS.java:42)
  at whelk.util.DFS.descend(DFS.java:55)
  at whelk.util.DFS.node(DFS.java:48)
  at whelk.util.DFS.traverse(DFS.java:22)
  at whelk.util.DocumentUtil.traverse(DocumentUtil.java:44)
  at whelk.util.FresnelUtil.insertComputedLabels(FresnelUtil.java:234)
  at whelk.rest.api.Crud.getNegotiatedDataBody(Crud.java:309)
  at whelk.rest.api.Crud.handleQuery(Crud.java:161)
  at whelk.rest.api.Crud.doGet2(Crud.java:135)
  at whelk.rest.api.Crud.doGet(Crud.java:115)
...

It's because _categoryByCollection gets @type null (retainLinks doesn't check if a type actually exists before setting it) and isTypedNode treats null as a typed node. This fix should take care of both problems.

@kaipoykio kaipoykio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thumbs up

@andersju
andersju merged commit 072bcd1 into develop Sep 23, 2026
1 check passed
@andersju
andersju deleted the fix/dont-set-or-accept-null-type branch September 23, 2026 10:58

@olovy olovy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants