plangrid/flask-rebar

prefixes with periods (".") cause flask's blueprint to complain that blueprint names can't have a period in them

rishi-matik opened this issue · 4 comments

To replicate, pass prefix="/api/1.0" as a kwarg to rebar.create_handler_registry. When init_app is called, Flask's blueprint complains that ValueError: 'name' may not contain a dot '.' character.

The issue originates at https://github.com/plangrid/flask-rebar/blame/master/flask_rebar/rebar.py#L620, where the blueprint name is prefixed by the url prefix for namespacing reasons I assume. I think the work around is to remove periods as that appears to be the only disallowed character in a Blueprint name (https://github.com/pallets/flask/blame/main/src/flask/blueprints.py#L186).

If we made this change would blueprints work with flask rebar?

I was under the impression that they don't work, but if this is the only reason, we can make the change.

If there is more in conflict, I would prefer to actually just have a feature request to support blueprints and add some tests then just make this one off change.

This is in reference to the blueprints being created by flask-rebar at https://github.com/plangrid/flask-rebar/blob/master/flask_rebar/swagger_ui/blueprint.py#L32 where the name being passed is generated at https://github.com/plangrid/flask-rebar/blame/master/flask_rebar/rebar.py#L620 by prepending the prefix (in our case this was "/api/1.0").

If the reason for prepending the prefix is for namespacing, then I think this is a reasonable solution.

ok, this makes sense.

fixed by #275