Repository navigation
Description
Observed/problematic behavior
8 public projects, all created between January and March 2023, have a link section whose links field is null instead of an array. This breaks two things:
1. The project page on hangar.papermc.io crashes (HTTP 500).
Opening any of these projects shows only:
An error occurred
null is not an object (evaluating 'item.id')
2. The API returns data that contradicts its own OpenAPI spec.
GET /api/v1/projects/Wanted returns:
"settings": {
"links": [
{
"id": 0,
"type": "top",
"title": "top",
"links": null
}
]
}The published spec (/v3/api-docs), however, marks LinkSection.links as required:
"LinkSection": {
"properties": { "id": {...}, "links": { "type": "array", "items": { "$ref": "#/components/schemas/Link" } }, "title": {...}, "type": {...} },
"required": ["links", "type"]
}Clients generated from the spec type this field as a non-nullable array. They crash when they read it. For example, the generated PHP client aternos/hangar-api throws:
TypeError: Aternos\HangarApi\Model\LinkSection::getLinks(): Return value must be of type array, null returned
Affected projects
I checked all projects returned by GET /api/v1/projects. These are the only ones with "links": null in a section. All of them have the same single section {"id": 0, "type": "top", "title": "top", "links": null}.
| ID | Project | Owner | Created | Page | API |
|---|---|---|---|---|---|
| 35 | CoinsAPI | TureBentzin | 2023-01-06 | 500 | json |
| 143 | TitansBattle | RoinujNosde | 2023-03-04 | 500 | json |
| 149 | Chainmailed | Paldiu | 2023-03-05 | 500 | json |
| 150 | Uncraftables | Paldiu | 2023-03-05 | 500 | json |
| 152 | FeelingLucky | Paldiu | 2023-03-05 | 500 | json |
| 157 | Wanted | Syrent | 2023-03-08 | 500 | json |
| 158 | VelocityReport | Syrent | 2023-03-08 | 500 | json |
| 159 | DatapackLoader | lichenaut | 2023-03-11 | 500 | json |
The project list endpoint does not return unlisted projects, so unlisted projects with the same problem may also exist.
No project returned settings.links: null, and no project had a Link without url.
Expected behavior
LinkSection.linksis always an array, as the OpenAPI spec promises. A section without links should be"links": [].- The project pages of these 8 projects load normally.
Both already work for projects with the same history whose links is not null:
SayanVanish (ID 156) is a good positive example. Its page returns 200 and its API response follows the spec:
"links": [
{
"id": 0, "type": "top", "title": "top",
"links": [
{ "id": 0, "name": "Homepage", "url": "https://github.com/Syrent/SayanVanish" },
{ "id": 1, "name": "Issues", "url": "https://github.com/Syrent/SayanVanish/issues" },
...
]
},
...
]An empty section works as well. LiteEco (ID 207) has {"id": 0, "type": "top", "title": null, "links": []} and its page returns 200. So [] is the correct value for a section without links.
null is what breaks.
Steps to reproduce
- Open https://hangar.papermc.io/Syrent/Wanted. The page shows "An error occurred – null is not an object (evaluating 'item.id')" with HTTP 500.
- Request
curl -s https://hangar.papermc.io/api/v1/projects/Wanted | jq .settings.links. It returns"links": nullinside the section. (see linked json response below) - Compare with
curl -s https://hangar.papermc.io/v3/api-docs | jq .components.schemas.LinkSection.required. It returns["links", "type"]. - As a counter-check, open https://hangar.papermc.io/Syrent/SayanVanish. It loads fine.
API response: project_157.json
Other
Why the spec says "required"
springdoc derives required from the @NotNull annotations on the API models:
LinkSection.links:LinkSection.java:12@NotNull @Validate(SpEL = "@validate.max(#root, 10)", message = "Too many links") List<@Valid Link> links
ProjectSettings.links:ProjectSettings.java:20Link.url:Link.java:7
The spec is therefore correct about what the backend accepts. Only the old data stored in the projects.links jsonb column does not match it. When the backend reads that column, the null passes straight through to the API response, because nothing validates the data on the way out.
Why new projects can no longer get into this state
All write paths validate these fields with @Valid. The validation cascades from the request form down to each LinkSection and Link:
- Project creation:
ProjectController.createProject(@RequestBody @Valid NewProjectForm).ProjectSettingsForm.settingsis@Valid,ProjectSettings.linksis@NotNull List<@Valid LinkSection>, andLinkSection.linksis@NotNull List<@Valid Link>. - Editing links:
ProjectController.saveProjectLinks(@RequestBody @Valid ProjectLinksForm), with the same cascade.
The validation was introduced in these commits:
| Date | Commit | Change |
|---|---|---|
| 2023-03-19 | e1f64f2 "feat: add backend for new link stuff" | Link rework: links move into the projects.links jsonb column (migration V1.4.0__link_rework.sql). No validation yet. |
| 2023-03-20 | 01909d6 "Add basic validation to project links, + i18n" | Adds @NotNull to LinkSection.links, LinkSection.type and ProjectSettings.links. |
| 2024-07-20 | 14d070f "fix: prevent saving empty links" | Adds @NotNull to Link.url. |
All 8 affected projects were created before 2023-03-20, so their data predates the validation.
Probable origin (not verified)
V1.4.0__link_rework.sql built every project's links from the old homepage, issues, source, support and wiki columns. It always produced an array of five links. For fields that were not set, it produced a link with "url": null. Today no project has a link with url: null anymore, so these links must have been removed later. No migration in the repository does this, so it was probably a manual cleanup on the production database.
If that cleanup rebuilt the array with jsonb_agg(...) WHERE url IS NOT NULL, every section in which all five URLs were null would end up as "links": null. In PostgreSQL, jsonb_agg over zero rows returns NULL, not []. This matches what we see: all 8 projects have the unchanged section from the migration (id: 0, type: "top", title: "top") with links: null. These are the projects that had none of the five old link fields set.
Proposed fix
- Data fix: normalize
projects.linksso that every section has an array inlinks(nullor a missing field becomes[]), and drop links without aurl. This also covers unlisted or hidden projects that the public API does not show. The migration is repeatable; on a second run, no rows will be updated. I've already prepared this PR: fix: normalize legacy project link sections (closes #1597) #1599 - Optional frontend hardening:
ProjectNav.vue:27uses.flatMap((section) => section.links). Withlinks: nullthis produces[null], soexternalLinks.lengthis 1 and the template then readsitem.idonnull. That is the 500 above. The link settings form (ProjectLinksForm.vue,topSection.value?.links.length) would likely fail the same way when an owner of one of these projects opens the link settings. I have not verified this, because it needs owner access. Once the data is fixed this cannot happen again, so hardening the frontend is optional.
Changing the spec to mark these fields as nullable is not the right fix. The backend never accepts null there, and doing so would force every API client to handle a case that only exists because of 8 old rows.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
pavog commentedon Oct 21, 2026
This SQL function should fix the broken link sections. I have tested and verified it against a local db installation.
Run the function on the projects table:
Drop the function after work is done:
We could also make a DB migration out of this, e.g.
backend/src/main/resources/db/migration/V1.29.0__fix_legacy_link_sections.sqlkennytv commentedon Oct 21, 2026
Thanks for the report, fixed in 5d940f2