Skip to content

Feedback/review #11

Description

@bhearsum

(@jbuck asked me to have a look at this, it seems like an issue is the easiest way to comment on the overall repo)

There's a couple of things that I definitely think need fixing:

And there's some other questions/comments. Whether or not you address them is up to you and @jbuck as far as I'm concerned:

  • I see from
    app.config.from_pyfile("config.py", silent=True)
    that Nazgul supports a config.py. Could you provide an sample/example one?
  • This repo should probably have https://pyup.io/ set-up to ensure dependencies do not get out of date.
  • data.sql appears to only contain a schema. It may be better called schema.sql? You could also consider using alembic to manage it, but it's probably overkill here.
  • It would be good to log errors in spots like https://github.com/mozilla-services/bouncer-admin/blob/master/nazgul/api.py#L37 where you're eating exceptions. Without them being logged, it can be extremely difficult to debug.
  • A 500 status code would be more appropriate in any place where you have an "Unknown error". Returning a 400 is a client error, and is usually reserved for when you know the client has made a mistake (for example, if they pass the wrong type for an argument).
  • Using autocommit is probably a bad idea, because it will commit after each statement. Doing this means that any API call that updates/inserts/deletes multiple rows could possibly commit only part of the request, which may cause an invalid or unknown state in the database. You should use transactions to ensure that each request is all or nothing. https://docs.sqlalchemy.org/en/13/orm/session_transaction.html
  • https://github.com/mozilla-services/bouncer-admin/blob/master/nazgul/api.py#L230 always returns a 400 status code, but it also appears to return data? Is that intended. It feels like a 200 would be better here.
  • Is there any way to run this locally? docker run complains about MySQL not being available.
  • I see the API is using xml responses. Is this required for backwards compatibility, or was it chosen for some other reason? If the latter, JSON would probably be a better choice.
  • Similarly, it would be more convenient/modern to use JSON for POST data. Uusing request.form means that clients must use x-www-form-urlencoded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions