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

Statically ensure that UserTopicVisibilityPolicy.unknown is not possible in our data models #1074

Open
PIG208 opened this issue Nov 22, 2024 · 1 comment
Labels
a-api Implementing specific parts of the Zulip server API help wanted

Comments

@PIG208
Copy link
Member

PIG208 commented Nov 22, 2024

This was brought up here: #1041 (comment).

UserTopicVisibilityPolicy.unknown allows us to deserialize unknown enum values gracefully at the edge.

static bool _warnInvalidVisibilityPolicy(UserTopicVisibilityPolicy visibilityPolicy) {
if (visibilityPolicy == UserTopicVisibilityPolicy.unknown) {
// Not a value we expect. Keep it out of our data structures. // TODO(log)
return true;
}
return false;
}

if (_warnInvalidVisibilityPolicy(visibilityPolicy)) {
visibilityPolicy = UserTopicVisibilityPolicy.none;
}

However, while we manually declare that it wouldn't be possible that we encounter UserTopicVisibilityPolicy.unknown when accessing our internal data store (i.e.: ChannelStore), our type doesn't agree with that, and require the UserTopicVisibilityPolicy.unknown case to be handled for an exhaustive switch. We use assert in such cases, but it is not supposed to be reachable (unless we have a bug).

We should make sure that such an assertion is not needed. This might require removing unknown from UserTopicVisibilityPolicy.

We specifically exclude UserTopicVisibilityPolicy.unknown at the edge. This may or may not apply to other unknown enum values. It would be good to do a sweep of those and decide if we need to follow-up on them as well.

@PIG208 PIG208 added help wanted a-api Implementing specific parts of the Zulip server API labels Nov 22, 2024
@PIG208 PIG208 added this to the M6: Post-launch milestone Nov 22, 2024
@RITWIZSINGH
Copy link

Hey there,
actually I am new to open source contribution
I want to ask how can i help towards solving this issue ?
Can you assign this issue to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-api Implementing specific parts of the Zulip server API help wanted
Projects
Status: No status
Development

No branches or pull requests

2 participants