Skip to content

Allow hyphens in location names in the legacy room export API - #7806

Open
Thanatos9404 wants to merge 3 commits into
indico:masterfrom
Thanatos9404:fix-rb-api-location-hyphen
Open

Thanatos9404 wants to merge 3 commits into
indico:masterfrom
Thanatos9404:fix-rb-api-location-hyphen

Conversation

@Thanatos9404

Copy link
Copy Markdown

Fixes #6527

The room and roomName export endpoints only accepted letters, digits, underscores and whitespace in the location part of the URL, so a location such as "HIM-Building 1395" never matched and the request failed. As ThiefMaster suggested in the issue, the location group of both hooks now uses [\w\s-]+. Slashes and dots are still excluded, so the location remains a single path segment. The reservation endpoint is left alone because it uses - to separate multiple locations, so a hyphenated name still cannot be passed there. I added a parametrized test for request path parsing that fails on master for the two hyphenated cases and passes with this change, and ruff and isort are clean.

@ThiefMaster

Copy link
Copy Markdown
Member

Looks like in this particular place we don't allow providing multiple values (which are typically dash-separated as well), so allowing dashes there may actually be possible!

@ThiefMaster

Copy link
Copy Markdown
Member

Did you actually test it btw? Ie both running the test and trying it out on an actual Indico server (ideally your own local dev setup where you have your patch applied)?

@Thanatos9404

Copy link
Copy Markdown
Author

Yes. The new test passes on the branch (its two hyphenated cases fail against master), and the whole indico/modules/rb suite passes against a real PostgreSQL. It was also tried on a local dev instance with the patch applied and a location named "HIM-Building 1395": /export/roomName/HIM-Building%201395/Pump.json and /export/room/HIM-Building%201395/1.json (with an API key) return the room, while on master the same URLs match no hook and 404. A location without a hyphen and the reservation export behave the same on both.

@ThiefMaster

Copy link
Copy Markdown
Member

Are you using an LLM to write these comments? 🙈

They read a bit like something an LLM would write...

@Thanatos9404

Copy link
Copy Markdown
Author

Yes, I used an AI assistant to understand the codebase and to help write the fix and these comments. The tests and the check on a local Indico instance described above were actually run.

This branch has not been deployed

No deployments
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.

Room booking plugin: Location name with "-" leads to error when using HTTP API access

2 participants