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

bug: GET /servers/{target}?include_channels=true creates JSON with duplicate keys #286

Closed
QuantumToasted opened this issue Nov 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@QuantumToasted
Copy link

QuantumToasted commented Nov 15, 2023

What happened?

As it says on the tin: GET /servers/{target}?include_channels=true will produce JSON similar to the following.

{
    "_id": "01H2SK15KZ914SN7MXDA5SFE4A",
    "channels": [
        "01H2SK15KZ05FZXV9XQ3QN1QBA",
        "01HEW15S36TG3XFK576GJKBF30",
        "01HF28N58Z8JZ896T1BHBJQ2A3",
        "01HF2BMN2Q64DP3TP43X3FA2G1"
    ],
	...,
    "channels": [
        {
            "channel_type": "TextChannel",
            "_id": "01H2SK15KZ05FZXV9XQ3QN1QBA",
            "server": "01H2SK15KZ914SN7MXDA5SFE4A",
            "name": "General",
            "last_message_id": "01HF2BMFGBJ30TSNYFRVZDGHH9"
        },
        {
            "channel_type": "TextChannel",
            "_id": "01HEW15S36TG3XFK576GJKBF30",
            "server": "01H2SK15KZ914SN7MXDA5SFE4A",
            "name": "test2"
        },
        {
            "channel_type": "VoiceChannel",
            "_id": "01HF28N58Z8JZ896T1BHBJQ2A3",
            "server": "01H2SK15KZ914SN7MXDA5SFE4A",
            "name": "yea"
        },
        {
            "channel_type": "TextChannel",
            "_id": "01HF2BMN2Q64DP3TP43X3FA2G1",
            "server": "01H2SK15KZ914SN7MXDA5SFE4A",
            "name": "balls"
        }
    ]
}

IMO, this should not be a valid response JSON. While a little research has told me that the initial JSON spec did not mention "duplicate keys" by name as to whether they're valid, many people tend to agree that it's bad practice at best and completely invalid JSON at worst. I would kindly ask that ?include_channels=true either replace the original channels ID array with the "full" channels object array, instead of this weird duplicate key response. Alternatively, you could introduce the field with a different name if consistency with other "server" JSON models is desired.

@QuantumToasted QuantumToasted added the bug Something isn't working label Nov 15, 2023
@Rexogamer
Copy link
Member

Can reproduce. The relevant code is here - it seems to me that the first channels property isn't being filtered out?

@insertish insertish transferred this issue from revoltchat/api Nov 15, 2023
@insertish
Copy link
Member

Can't reproduce this anymore, assuming fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants