Modify

Opened 3 years ago

Last modified 3 years ago

#21826 new enhancement

[WIP patch] Upcoming API 0.6 change: limit maximum number of relation members

Reported by: mmd Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: api capabilities limit relation Cc:

Description

We will deploy a new API 0.6 change shortly, which will reject relations exceeding a certain number of relation members.

The overall logic is very similar to "waynodes", only that it applies to relation members this time, i.e. you need to use the /api/0.6/capabilities endpoint to retrieve the current maximum relation member value.

It would be good to show an error message to the user even before uploading, like it is done today for "waynodes" in ApiPreconditionCheckerHook.

Please refer to the following two issues on impact on the capabilities call, as well as new API error messages.

https://github.com/openstreetmap/openstreetmap-website/pull/3440
https://github.com/openstreetmap/openstreetmap-website/issues/1711

Snipped from capabilities which includes the new relationmembers element:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
  <api>
    <version minimum="0.6" maximum="0.6"/>
    <area maximum="0.25"/>
    <note_area maximum="25"/>
    <tracepoints per_page="5000"/>
    <waynodes maximum="2000"/>
    <relationmembers maximum="32000"/>
    <changesets maximum_elements="10000"/>
    <timeout seconds="300"/>
    <status database="online" api="online" gpx="online"/>
  </api>
  <policy>
    <imagery>
      <blacklist regex=".*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*"/>
      <blacklist regex="http://xdworld\.vworld\.kr:8080/.*"/>
      <blacklist regex=".*\.here\.com[/:].*"/>
    </imagery>
  </policy>
</osm>

Attachments (2)

josm_21826_wip.patch (6.9 KB ) - added by gaben 3 years ago.
add support for capabilities on max relation members (checked only on upload)
josm_21826_v2.patch (8.7 KB ) - added by gaben 3 years ago.
fix typo, allow deleting over the API limit

Download all attachments as: .zip

Change History (14)

comment:1 by gaben, 3 years ago

Keywords: api capabilities limit relation added
Summary: Upcoming API 0.6 change: limit maximum number of relation members[WIP patch] Upcoming API 0.6 change: limit maximum number of relation members
Type: defectenhancement

by gaben, 3 years ago

Attachment: josm_21826_wip.patch added

add support for capabilities on max relation members (checked only on upload)

comment:2 by Woazboat, 3 years ago

The second function arguments here should probably be maxMembers and not maxNodes?

 	55	            long maxMembers = api.getCapabilities().getMaxRelationMembers();
 	56	            if (maxMembers > 0) {
 	57	                if (!checkMaxMembers(apiData.getPrimitivesToAdd(), maxNodes))
 	58	                    return false;
 	59	                if (!checkMaxMembers(apiData.getPrimitivesToUpdate(), maxNodes))
 	60	                    return false;
 	61	                if (!checkMaxMembers(apiData.getPrimitivesToDelete(), maxNodes))
 	62	                    return false;
 	63	            }

comment:3 by Woazboat, 3 years ago

Deleting relations with too many members should still be possible as far as I can tell from looking at the proposed api changes. The maxMember preconditions are only checked when creating or updating relations.

https://github.com/openstreetmap/openstreetmap-website/blob/2efd73c672dae8f6956024638b4b090961e74781/app/models/relation.rb#L163.L182

comment:4 by Woazboat, 3 years ago

Adding a check to the relation editor to detect these errors while editing (and prevent too many members from being added in the first place) and not just when attempting to upload the changes would also be a good idea.

comment:5 by gaben, 3 years ago

Thanks! Yes, it's a copy-paste error.

Deleting possibility over the limit sounds logical to me, but then why is it denying upload over the limit of way nodes? I didn't know the reason, so copied the functionality.

in reply to:  4 ; comment:6 by skyper, 3 years ago

Replying to Woazboat:

Adding a check to the relation editor to detect these errors while editing (and prevent too many members from being added in the first place) and not just when attempting to upload the changes would also be a good idea.

As relation editor is only one place, I'd rather go with a validator error warning like relations without members.

comment:7 by mmd, 3 years ago

Deleting relations with too many members should still be possible as far as I can tell from looking at the proposed api changes.

That's correct, we want mappers to still be able to delete those relations.

comment:8 by mmd, 3 years ago

why is it denying upload over the limit of way nodes? I didn't know the reason, so copied the functionality.

I guess those ways have been cleaned up (manually?) right before API 0.6 went live years ago. Nevertheless, the API would allow deleting such ways with more than 2000 nodes.

in reply to:  6 ; comment:9 by Woazboat, 3 years ago

Replying to skyper:

Replying to Woazboat:

Adding a check to the relation editor to detect these errors while editing (and prevent too many members from being added in the first place) and not just when attempting to upload the changes would also be a good idea.

As relation editor is only one place, I'd rather go with a validator error warning like relations without members.

Why not both?

in reply to:  9 ; comment:10 by skyper, 3 years ago

Replying to Woazboat:

Replying to skyper:

Replying to Woazboat:

Adding a check to the relation editor to detect these errors while editing (and prevent too many members from being added in the first place) and not just when attempting to upload the changes would also be a good idea.

As relation editor is only one place, I'd rather go with a validator error warning like relations without members.

Why not both?

Mmh, I am no fan of constantly validating as it uses resources and in this case, I think the situation will happen rarely. At least an option to disable it would be nice.

by gaben, 3 years ago

Attachment: josm_21826_v2.patch added

fix typo, allow deleting over the API limit

in reply to:  10 ; comment:11 by SImonPoole, 3 years ago

Replying to skyper:
...

Mmh, I am no fan of constantly validating as it uses resources and in this case, I think the situation will happen rarely. At least an option to disable it would be nice.

The issue is that splitting ways and similar operations will increase relation member count without direct involvement of the user. That is it is quite possible to be slightly under the limit and then with a few way splits go over it (at 32'000 members that is obviously going to extremely rare, but just wait till it comes down to 10'000 or lower). Failing on upload is just not good UX design in such a situation.

in reply to:  11 comment:12 by skyper, 3 years ago

Replying to SImonPoole:

Replying to skyper:
...

Mmh, I am no fan of constantly validating as it uses resources and in this case, I think the situation will happen rarely. At least an option to disable it would be nice.

The issue is that splitting ways and similar operations will increase relation member count without direct involvement of the user. That is it is quite possible to be slightly under the limit and then with a few way splits go over it (at 32'000 members that is obviously going to extremely rare, but just wait till it comes down to 10'000 or lower). Failing on upload is just not good UX design in such a situation.

We can always show a validator error for the limit before upload instead of checking all involved relations on each change.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to mmd.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.