Skip to content

TWFY api returns invalid json when reporting postcode errors, and possibly others #811

@ianheggie-oaf

Description

@ianheggie-oaf

Describe the bug

api returns invalid json when reporting postcode errors, and possibly others.

To Reproduce

  1. Navigate to https://www.openaustralia.org.au/api/key to obtain your API key
  2. Navigate to https://www.openaustralia.org.au/api/getDivisions?output=js&key=[KEY]&postcode=0100 (Replacing [KEY] with your key)

Expected behavior

It should produce valid JSON output:

{"error":"Unknown postcode"}

Screenshots/Output

It produces invalid JSON output:

{"error":"Unknown postcode"}{}

Additional context

Its likely that api_error is being called without an exit to stop a following api_output being called. I noticed a number of places where this problem was present when investigating:

Not a problem everywhere, for example:
https://test.openaustralia.org.au/api/getDivisions?output=js&key=BADKEY&postcode=3000 works as expected

produces a valid json error response:

{"error":"Invalid API key."}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions