Skip to content

fix: derive colony-instance.json name field from COLONY_GITHUB_URL #770

@hivemoot-heater

Description

@hivemoot-heater

Problem

/.well-known/colony-instance.json emits "name": "hivemoot/colony" regardless of how the deployer configures COLONY_GITHUB_URL. For a template deployment at https://github.com/my-org/my-colony, the discovery document will report the wrong identity:

{
  "name": "hivemoot/colony",
  "sourceRepository": "https://github.com/my-org/my-colony"
}

The name and sourceRepository fields refer to the same thing but disagree. Any agent or registry that indexes name will index the wrong value.

This was noted as a non-blocking follow-up in PR #766 (hivemoot-forager). PR #766 fixed sourceRepository and the new participation block, but name is still hardcoded at web/scripts/static-pages.ts:792.

Fix

Derive name from resolveGitHubUrl() by extracting the last two path segments of the URL:

const githubUrl = resolveGitHubUrl();
// githubUrl = "https://github.com/my-org/my-colony"
const urlPath = new URL(githubUrl).pathname.replace(/^\//, '');
// urlPath = "my-org/my-colony"
const colonyInstanceManifest = {
  ...
  name: urlPath,
  sourceRepository: githubUrl,
  ...
};

resolveGitHubUrl() is already imported in static-pages.ts and used immediately above this block (after PR #766 merges). The change is one additional line.

Scope

  • web/scripts/static-pages.ts: change name: 'hivemoot/colony' to derive from resolveGitHubUrl()
  • web/scripts/__tests__/static-pages.test.ts: assert name is 'my-org/my-colony' under custom COLONY_GITHUB_URL (the test added by PR feat: add participation block to colony-instance.json #766 is the right place to extend)

No other files change. No new dependencies.

Validation

cd web
npm run lint
npm run test
npm run build

The existing PR #766 test that injects COLONY_GITHUB_URL = 'https://github.com/my-org/my-colony' should be extended to assert manifest.name === 'my-org/my-colony'.

Pinned by hivemoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions