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

Add fallback for role descriptions #1905

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Jan 9, 2024

Followup to #1904. Just as already done for team names and team descriptions, if a new role is added in the rust-lang/team repo, www will render it using the en-US text supplied in teams.json until translations appear in this repo.

Before:

After:

@dtolnay
Copy link
Member Author

dtolnay commented Jan 9, 2024

CI failure is fixed by #1906.

@dtolnay
Copy link
Member Author

dtolnay commented Jan 9, 2024

Rebased on #1906.

src/i18n.rs Outdated
return role["description"].as_str().unwrap();
}
}
panic!("no role {:?}", role_id);
Copy link
Member

Choose a reason for hiding this comment

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

issue: let's fail gracefully; I don't want the website to crash whenever the teams repo is updated

I'd just have it output the role ID

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this would crash on a team repo update — the JSON looks like this:

{
  "name": "spec",
  "members": [
    ...
    {
      "name": "Joel Marcey",
      "github": "JoelMarcey",
      "roles": [
        "spec-editor"
      ]
    }
  ],
  "website_data": {
    "name": "Specification team",
    "description": "Creating and maintaining the specification for the Rust language",
    "page": "spec",
    ...
  },
  "roles": [
    {
      "id": "spec-editor",
      "description": "Editor"
    }
  ]
}

where .members.*.roles.* are guaranteed to line up with exactly one .roles.*.id.

There is a test here to enforce it:

https://github.com/rust-lang/team/blob/ae0fe5cb83bbb24c9533c6829f2ca11667e8ab2d/src/validate.rs#L840-L849

The static-api teams.json cannot be published without that validation passing.

We can make this more robust to broken teams.json but all the other unwraps in this code would also be crashable in that situation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to return role_id, with a comment saying it should be unreachable.

@dtolnay
Copy link
Member Author

dtolnay commented Jan 9, 2024

CI failure is fixed by #1910.

@Manishearth Manishearth closed this Jan 9, 2024
@Manishearth Manishearth reopened this Jan 9, 2024
@Manishearth Manishearth merged commit 0b933a8 into rust-lang:master Jan 15, 2024
1 check passed
@dtolnay dtolnay deleted the fallback branch January 15, 2024 01:01
@dtolnay dtolnay mentioned this pull request Jan 15, 2024
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.

None yet

2 participants