dedis/popstellar

[BUG] Scala paged catchup invalid channel error not in line with specification

osm-alt opened this issue · 0 comments

Description (Actual behavior)

When sending a paged catchup message with a channel parameter that is invalid, Scala is currently validating the Regex for the channel specified in the paged catchup JSON schema (^/root(/[^/]+)/social/(chirps(/[^/]+)|profile(/[^/]+){2})$), and returns the following error:

{
    "jsonrpc": "2.0",
    "id": 3,
    "error": {
        "code": -4,
        "description": "$.method: must be a constant value heartbeat; $: should be valid to one and only one schema, but 0 are valid; $.params.timestamp: is missing but it is required; $.method: must be a constant value greet_server; $.method: must be a constant value get_messages_by_id; $.params.messages: is missing but it is required; $.params.channel: does not match the regex pattern ^/root(/[^/]+)/social/(chirps(/[^/]+)|profile(/[^/]+){2})$; $.params.client_address: is missing but it is required; $.params: is not defined in the schema and the schema does not allow additional properties; $.params.channel: is not defined in the schema and the schema does not allow additional properties; $.method: must be a constant value rumor; $.method: must be a constant value unsubscribe; $.result: is missing but it is required; $.params.number_of_messages: is not defined in the schema and the schema does not allow additional properties; $.params.number_of_messages: is not defined in the schema and the schema does not allow additional properties; $.params.public_key: is missing but it is required; $.params.sender_id: is missing but it is required; $.params.before_message_id: is not defined in the schema and the schema does not allow additional properties; $.method: must be a constant value rumor_state; $.method: must be a constant value subscribe; $.method: must be a constant value catchup; $.params.channel: is not defined in the schema and the schema does not allow additional properties; $.params.before_message_id: is not defined in the schema and the schema does not allow additional properties; $.method: must be a constant value broadcast; $.method: is not defined in the schema and the schema does not allow additional properties; $.error: is missing but it is required; $.params.state: is missing but it is required; $.method: must be a constant value publish; $.params.server_address: is missing but it is required; $.id: is not defined in the schema and the schema does not allow additional properties; $.params.message: is missing but it is required; $.params.rumor_id: is missing but it is required"
    }
}

Expected behavior

In protocol.md, it says: "If a paged catchup message is sent on another channel, the backend returns an error with a -1 code indicating that this is an invalid action and a description saying that paging is not supported on this channel."

How to reproduce

Send a paged catchup message with an invalid channel parameter.
An example:

{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "paged_catchup",
    "params": {
        "channel": "/root/89zterjThplXCrimBjyNfxvXKNS4QdW5QN-bEtHL00Y=/social/chrs/hYzX2BeT1juKnxymB0aK3VlTA8r7JSrGThc7Mby45aA=",
        "number_of_messages": 10,
        "before_message_id": "to6etYtCCHK7HSGHoOzqVqTKzMK2IHMyuez-yRESlc4="
    }
}
Front-ends:
  • Fe1-Web (please include browser's names & version)
  • Fe2-Android (please specify if phone or emulation, and Android version)
  • Not applicable
Back-ends:
  • Be1-Go
  • Be2-Scala
  • Not applicable