Skip to content

Fix/ooniprobe diff#1086

Merged
aagbsn merged 8 commits intomasterfrom
fix/ooniprobe-diff
Feb 20, 2026
Merged

Fix/ooniprobe diff#1086
aagbsn merged 8 commits intomasterfrom
fix/ooniprobe-diff

Conversation

@hellais
Copy link
Member

@hellais hellais commented Feb 17, 2026

This addresses the diffs in this endpoint identified in the test deployment here: ooni/devops#300

@aagbsn
Copy link
Contributor

aagbsn commented Feb 17, 2026

I think this looks good and illustrates the importance of writing the correct tests.

Copy link
Contributor

@aagbsn aagbsn left a comment

Choose a reason for hiding this comment

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

This looks good; thanks for catching these mistakes. The FastAPI post handling for Optional fields is a bit confusing to me though; how does the debug_prioritization endoint not complain about a missing parameters without Optional?

)
def debug_prioritization(
clickhouse: ClickhouseDep,
probe_cc: Optional[str] = Query(description="2-letter Country-Code", default="ZZ"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why the test added is returning status 200 if non-optional parameters are not supplied

Copy link
Member Author

Choose a reason for hiding this comment

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

Because if it's set to Optional (i.e. nullable) with a default value set, effectively it's never possible for it to assume the None value, hence the correct typing should be str

Copy link
Contributor

Choose a reason for hiding this comment

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

ok this is a bit confusing: as a URL parameter; if it is NOT set to optional but has a default value set, it effectively is optional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Something like that. The thing is that there is no way to specify using HTTP semantics that this field which has a default value should actually be none

assert resp.status_code == 200
assert resp.headers["content-type"] == "application/json"

resp = client.get("/api/_/debug_prioritization")
Copy link
Contributor

@aagbsn aagbsn Feb 18, 2026

Choose a reason for hiding this comment

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

see comment above; probe_cc isn't supplied in this test - so the Query parameter is effectively optional if a default value is supplied? That's why I'm surprised this test passes, because I thought Optional[] was used to indicate whether the parameter was required or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is that all values have now defaults set, which is the behaviour we had in the previous version of it. So now because there are always defaults, the call to generate_test_list is successful, while previously it failed when probe_asn was none

@aagbsn aagbsn merged commit 4a0b0f8 into master Feb 20, 2026
7 checks passed
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.

2 participants