opensafely-core / opensafely-core/osgithub

Break apart Contents Abstraction

Open
#55 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
0
Avg merge
2d 20h
Merged PRs (30d)
9

Description

We currently have GithubRepo.get_contents as an abstraction around GitHub's Contents API endpoint. However, this endpoint behaves differently depending on what you're asking it for, in particular:

  • a directory
  • a file
  • a file whose size is between 1MB and 100MB
  • a file whose size is above 100MB

The method tries to handle those all in one place and the flow suffers because of it.

Instead we should pick apart this abstraction into two, based on the caller's intent:

  • a directory
  • a file, with fallbacks for larger files

For instance, file content for files between 1MB and 100MB can be retrieved with the application/vnd.github.v3.raw custom media type (as the Accept header). Since we already want the metadata from the initial call (it's not provided with a raw call) this seems like a nice fallback. We can discuss whether we need to support retrieving file content which is >100MB.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GithubRepo.get_contents and the linked GitHub Contents API documentation, then trace its callers to distinguish directory and file intent. Define separate behavior for directories and files, including the raw-media fallback for files between 1MB and 100MB; the issue also requires deciding whether files over 100MB must be supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, python
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.