Skip to content

fix: allow non-present avatar_url in addition to explicit null - #939

Open
RasmusRendal wants to merge 3 commits into
matrix-org:mainfrom
RasmusRendal:RasmusRendal/null_avatar_url
Open

RasmusRendal wants to merge 3 commits into
matrix-org:mainfrom
RasmusRendal:RasmusRendal/null_avatar_url

Conversation

@RasmusRendal

Copy link
Copy Markdown

When no avatar is set, Synapse might still return {"avatar_url": null} in response to /joined_members. But {} contains the same information, and should therefore also be accepted by Complement.

Pull Request Checklist

@RasmusRendal
RasmusRendal requested review from a team as code owners October 22, 2026 11:47
@RasmusRendal
RasmusRendal requested review from MadLittleMods and removed request for a team October 22, 2026 11:47
Comment thread tests/csapi/apidoc_room_state_test.go Outdated
match.JSONKeyPresent("joined." + authedClient.UserID),
match.JSONKeyPresent("joined." + authedClient.UserID + ".display_name"),
match.JSONKeyPresent("joined." + authedClient.UserID + ".avatar_url"),
match.JSONKeyMissingOrNull("joined." + authedClient.UserID + ".avatar_url"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's spawning this change? Why did you create the PR?

Another homeserver implementation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh right, this change is motivated by work on the Arminius homeserver implementation :)

We use ruma types, which tend to prefer leaving keys out rather than setting them to null, which is causing us to fail this test in particular.
I haven't looked at it in depth, but I could imagine that Continuwuity fails this test for similar reasons.

Comment thread tests/csapi/apidoc_room_state_test.go Outdated
match.JSONKeyPresent("joined." + authedClient.UserID),
match.JSONKeyPresent("joined." + authedClient.UserID + ".display_name"),
match.JSONKeyPresent("joined." + authedClient.UserID + ".avatar_url"),
match.JSONKeyMissingOrNull("joined." + authedClient.UserID + ".avatar_url"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test doesn't have a description but if the point of this test is to assert the shape of the response, feels like we should either a) add an actual avatar_url and assert JSONKeyPresent or b) no avatar and expect JSONKeyMissing.

Option a) would allow Synapse to keep passing with this specific test and have the best coverage if we only have a single test to cover this 🤷

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I went for a), because it feels quite mean to make Synapse (and the other homeservers that already pass here) fail a test when they're not strictly speaking breaking the spec

Comment thread tests/csapi/apidoc_room_state_test.go Outdated
match.JSONKeyPresent("joined." + authedClient.UserID),
match.JSONKeyPresent("joined." + authedClient.UserID + ".display_name"),
match.JSONKeyPresent("joined." + authedClient.UserID + ".avatar_url"),
match.JSONKeyMissingOrNull("joined." + authedClient.UserID + ".avatar_url"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As a note, right now, the test is half-baked since it doesn't assert the type of the value either (we could use JSONKeyEqual or JSONKeyTypeEqual if we don't know the expected value) but prior art so we don't have to dwell on this ⏩

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I included a commit here fixing it for the last two keys :)

@RasmusRendal
RasmusRendal force-pushed the RasmusRendal/null_avatar_url branch 2 times, most recently from 6e7e676 to a6a8326 Compare October 27, 2026 08:30
Previously the test would expect `avatar_url` to be `null`, failing on
tests where the `avatar_url` would be non-present when unset.
Now we set an `avatar_url` to make sure that the key is set.

Signed-off-by: Rasmus Rendal <r.kjaer@famedly.com>
…hip test

We know the type and the entire key in these two cases, so we might as
well test it.

Signed-off-by: Rasmus Rendal <r.kjaer@famedly.com>
@RasmusRendal
RasmusRendal force-pushed the RasmusRendal/null_avatar_url branch from a6a8326 to 17a41b5 Compare October 27, 2026 08:34
@MadLittleMods
MadLittleMods self-requested a review October 27, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants