Skip to content

fix(api): only link and show datasets and use cases the caller may see - #360

Merged
anantjain341 merged 1 commit into
CivicDataLab:devfrom
anantjain341:fix/link-draft-visibility
Dec 2, 2026
Merged

anantjain341 merged 1 commit into
CivicDataLab:devfrom
anantjain341:fix/link-draft-visibility

Conversation

@anantjain341

Copy link
Copy Markdown
Contributor

Linking a dataset or use case into a collaborative or use case only checked the item being changed, and the linked lists returned every linked item. Someone could link another organisation's draft into their own collaborative and read it back there. Now linking and reading both follow the same visibility rules as getDataset and useCase(pk): published items for everyone; drafts for the owner, members of the item's organisation whose role can view, people with a dataset grant, and superusers.

Linking

  • addDatasetToCollaborative, addUsecaseToCollaborative, addDatasetToUseCase: an item the caller may not see is refused with the same error as a wrong id (Dataset with ID … does not exist.), so a hidden draft cannot be told apart from a missing one.
  • updateCollaborativeDatasets, updateCollaborativeUseCases, updateUsecaseDatasets: a hidden id gets the existing error These dataset ids do not exist: … and nothing is saved.
  • When a list is replaced, links the caller cannot see are kept: they never received them, so their list cannot name them. Superusers can replace everything.
  • Published items and the caller's own or own organisation's drafts link as before.

Reading

Each reader sees only the linked items they may see, in:

  • collaborative datasets, useCases, datasetCount, useCaseCount, publishers
  • use case datasets, datasetCount, publishers
  • datasetByCollaborative, datasetByUseCase

This also hides links made before this change. Collaborative and use case search results list only published linked datasets and use cases.

# Signed in as someone outside the draft's organisation
mutation { addDatasetToCollaborative(collaborativeId: "12", datasetId: "<other org's draft>") { id } }
# -> error "Dataset with ID <id> does not exist." (same as a wrong id)

API

No field, argument or type changes. Counts and publishers now match the list the reader is shown.

Deploy

No migration and no mapping change; the release search refill rewrites collaborative and use case entries.

Linking a dataset or use case into a collaborative or use case checked
only the item being changed and loaded the linked one by id alone, and
the linked lists returned every linked item. A signed-in user could
link another organisation's draft into their own collaborative and read
its title and fields back there; use case ids are sequential.

Linking now accepts only items the caller may see, with the same rules
as getDataset and useCase(pk); anything else answers like a missing id.
The linked lists, their counts and publishers show each reader only the
items they may see, which also hides links made before this change.
Search entries carry published linked items only. Replacing a list
keeps the links the editor cannot see, since their list cannot name
them.
@anantjain341
anantjain341 merged commit c43da0a into CivicDataLab:dev Dec 2, 2026
4 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.

1 participant