Skip to content

refactor(datasource): normalise github getDigest signatures - #46187

Draft
secustor wants to merge 2 commits into
secustor/refactor/datasource-github-release-attachments-subclassfrom
secustor/refactor/datasource-github-get-digest-signatures
Draft

secustor wants to merge 2 commits into
secustor/refactor/datasource-github-release-attachments-subclassfrom
secustor/refactor/datasource-github-get-digest-signatures

Conversation

@secustor

Copy link
Copy Markdown
Member

Changes

DatasourceApi.getDigest?(config, newValue?) is called by the registry with an optional value, but github-releases and github-release-attachments declared newValue: string as required, which TypeScript only accepts because method parameters are bivariant. github-tags and github-digest had already been normalised by the registry-url layer below.

  • Both datasources now declare getDigest(config, newValue?: string) and return null explicitly when no value is given, matching github-digest. One spec case per datasource proves it.
  • The getDigest doc comment in types.ts and datasource.ts states that newValue may be undefined and what an implementation must return in that case.

Behaviour: the registry path is unchanged. Called without a value, github-releases no longer issues a GraphQL tags query it could not use, and github-release-attachments no longer risks requesting a release named undefined.


Part of the datasource base-class stack; this layer sits on the github-release-attachments subclass PR and only contains its own changes.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Code, tests and this description were written with Claude Code (Claude Fable 5.1) under the author's direction and review.

Use of AI in replying to PR comments

Who answers review comments:

  • @secustor will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted. Name the account.
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

The DatasourceApi.getDigest contract accepts newValue?: string, and the
datasource index calls getDigest with a possibly-undefined value. Both
GithubReleasesDatasource and GithubReleaseAttachmentsDatasource declared
newValue as required, only accepted because TypeScript method parameters
are bivariant, so an undefined value could reach findCommitOfTag() or the
release-tag lookup at runtime without the type system catching it.

Both classes now declare newValue?: string and return null immediately
when it is missing, matching GithubDigestDatasource's existing pattern.
GithubTagsDatasource and GithubDigestDatasource already used this shape
and are unchanged.

Also tightens the getDigest doc comment (in datasource.ts and types.ts)
to note that newValue may be undefined and that implementations must
handle that case explicitly.

Behaviour change: none for the registry path, which already only ever
passed a real string or undefined. In GithubReleasesDatasource, a missing
newValue now returns null without issuing a GraphQL tags query (previously
the query ran and still resolved no matching tag, returning null). In
GithubReleaseAttachmentsDatasource, a missing newValue with a resolvable
currentValue/currentDigest now returns null immediately instead of
attempting a request for release tag "undefined", which could previously
throw or produce an incorrect currentDigest fallback.
@secustor
secustor added this pull request to stack #46110 September 15, 2026 00:27

This branch has not been deployed

No deployments
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