I had a CTE:
prod_document_issues_completeness as (
select prod_issue_ids.id, coalesce(is_complete, false) as complete
from prod_issue_ids
inner join document_issue di
on prod_issue_ids.id = di.issue_id
and di.document_id = $1
and di.section_id is null
left join llm_run lr
on di.id = lr.document_issue_id
and lr.creation_reason = 'document_upload'
),
before instead of the left join, I was using an inner join. This was bad because some document issues that were production didn’t yet have a row in the llm_run table, so I wan’t taking them into account. Similarly, when I put a typo in the document-upload, it didn’t take them into account, so the thing broke.