Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter duplicate co-authors from SpaceDock #3599

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

HebaruSan
Copy link
Member

Problem

This mod:

https://spacedock.info/mod/2992/SRB%20Waterfall%20Effects%20(SWE)

... gave me this inflation error locally after fixing the install to match the latest download:

Schema validation failed: #/author: NotOneOf

Cause

The co-author was added twice:

image

... which we simply dumped into a List<string>, but it's not allowed in the schema (note uniqueItems):

CKAN/CKAN.schema

Lines 47 to 57 in 4f3da57

"author" : {
"description" : "Author, or list of authors",
"oneOf" : [
{ "type" : "string" },
{
"type" : "array",
"items" : { "type" : "string" },
"uniqueItems" : true
}
]
},

Since neither the simple string format nor the unique-array format matched, the validator considered the oneOf to be the thing that failed.

Changes

Now the SpaceDock translator ensures co-author uniqueness with .Distinct(). Initially I looked at using a HashSet, but then we would lose the ordering of the authors. I wanted to avoid generating more temporary values, and since you can't add yourself as a co-author, this seemed sufficient to cover the problematic cases.

I audited the GitHub translator and as far as I can tell it already ensures uniqueness with .Contains() calls. I don't think any of the other translators can generate multiple authors.

This should probably also be fixed on the SpaceDock side at some point, but it's good to satisfy constraints in the same project that imposes them.

@HebaruSan HebaruSan added Bug Something is not working as intended Pull request Netkan Issues affecting the netkan data labels Jun 30, 2022
Copy link
Member

@techman83 techman83 left a comment

Choose a reason for hiding this comment

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

Yep, that looks to be a sensible approach.

@HebaruSan HebaruSan merged commit a0a3580 into KSP-CKAN:master Aug 4, 2022
@HebaruSan HebaruSan deleted the fix/sd-dup-auths branch August 4, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Netkan Issues affecting the netkan data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants