Skip to content

feat: publish subgraph hash configmap#39

Merged
roderik merged 1 commit intomainfrom
codex/add-subgraph_hash-env-var-for-config-map
Sep 21, 2025
Merged

feat: publish subgraph hash configmap#39
roderik merged 1 commit intomainfrom
codex/add-subgraph_hash-env-var-for-config-map

Conversation

@roderik
Copy link
Copy Markdown
Member

@roderik roderik commented Sep 21, 2025

Summary

  • add a helper to load and validate the subgraph hash from a file
  • include the subgraph hash ConfigMap in file and Kubernetes outputs with a default name
  • wire the generate command to read the optional subgraph hash file and extend tests

Testing

  • bun test
  • bun run typecheck
  • bun run check

https://chatgpt.com/codex/tasks/task_e_68cf2d48dc44833287e31391dee5278e

Summary by Sourcery

Add support for loading and publishing a subgraph IPFS hash as a ConfigMap in the network bootstrap process.

New Features:

  • Introduce loadSubgraphHash helper to read and validate an IPFS hash from a file
  • Add --subgraph-hash-file CLI option and SUBGRAPH_HASH_FILE environment variable to specify the subgraph hash file
  • Include subgraph hash in payload and publish it as a ConfigMap in both file and Kubernetes outputs

Build:

  • Add multiformats dependency for IPFS CID parsing

Documentation:

  • Document the new --subgraph-hash-file option in the README

Tests:

  • Add unit tests for loadSubgraphHash to validate file existence, emptiness, and CID format
  • Extend bootstrap command and output tests to cover subgraph hash loading and ConfigMap generation

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @roderik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the network bootstrapper by enabling the publication of a subgraph IPFS hash as a Kubernetes ConfigMap or a local file. This feature allows users to easily manage and distribute the hash of their deployed subgraphs, ensuring consistency across environments. The change introduces a new CLI option and environment variable for specifying the hash file, along with validation to ensure the hash's integrity.

Highlights

  • Subgraph Hash Configuration: Introduced the ability to read an IPFS subgraph hash from a file and publish it as a ConfigMap.
  • CLI Integration: Added a new command-line option --subgraph-hash-file to specify the path to the subgraph hash file.
  • Environment Variable Support: The subgraph hash file path can also be provided via the SUBGRAPH_HASH_FILE environment variable.
  • Output Generation: The subgraph hash is now included in both file-based and Kubernetes ConfigMap outputs.
  • Validation: Implemented robust validation to ensure the provided subgraph hash is a valid IPFS CID using the multiformats library.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the qa:running QA workflow is currently running label Sep 21, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 21, 2025

To view in Slack, search for: 1758440325.371649

@github-actions github-actions Bot added qa:success QA workflow passed successfully feat New feature status:ready-for-review Pull request is ready for review and removed qa:running QA workflow is currently running labels Sep 21, 2025
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/cli/commands/bootstrap/bootstrap.command.ts:407` </location>
<code_context>
     ? await deps.loadAbis(trimmedAbiDirectory)
     : [];

+  const envSubgraphHashFile = Bun.env.SUBGRAPH_HASH_FILE?.trim();
+  const providedSubgraphHashFile =
+    subgraphHashFileOption === undefined
</code_context>

<issue_to_address>
**suggestion:** Subgraph hash file path is trimmed but not normalized for possible surrounding quotes.

Please apply `stripSurroundingQuotes` to the subgraph hash file path to ensure consistent normalization and prevent issues when quotes are present.

Suggested implementation:

```typescript
  const envSubgraphHashFile = stripSurroundingQuotes(Bun.env.SUBGRAPH_HASH_FILE?.trim());
  const providedSubgraphHashFile =
    subgraphHashFileOption === undefined
      ? undefined
      : stripSurroundingQuotes(subgraphHashFileOption.trim());
  let subgraphHashPath: string | undefined;
  if (providedSubgraphHashFile && providedSubgraphHashFile.length > 0) {
    subgraphHashPath = providedSubgraphHashFile;
  } else if (envSubgraphHashFile && envSubgraphHashFile.length > 0) {
    subgraphHashPath = envSubgraphHashFile;
  }

```

Make sure that `stripSurroundingQuotes` is imported or available in this file. If it's not already imported, add:
```ts
import { stripSurroundingQuotes } from 'path/to/stripSurroundingQuotes';
```
at the top of the file, adjusting the import path as needed.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively adds support for publishing a subgraph IPFS hash as a ConfigMap, mirroring the handling of other network artifacts. The changes include a new CLI option, environment variable support, a validation helper for the hash, and integration into both file and Kubernetes outputs. The accompanying tests are thorough, covering the new logic and ensuring existing functionality remains intact. I've provided a couple of suggestions to simplify some of the new logic, which will enhance readability and maintainability.

Comment on lines +344 to +348
if (originalEnv === undefined) {
Bun.env.SUBGRAPH_HASH_FILE = undefined;
} else {
Bun.env.SUBGRAPH_HASH_FILE = originalEnv;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The finally block for restoring the SUBGRAPH_HASH_FILE environment variable can be simplified. The if/else statement is not necessary, as assigning originalEnv (which can be a string or undefined) directly to Bun.env.SUBGRAPH_HASH_FILE achieves the same result more concisely.

      Bun.env.SUBGRAPH_HASH_FILE = originalEnv;

Comment on lines +407 to +417
const envSubgraphHashFile = Bun.env.SUBGRAPH_HASH_FILE?.trim();
const providedSubgraphHashFile =
subgraphHashFileOption === undefined
? undefined
: subgraphHashFileOption.trim();
let subgraphHashPath: string | undefined;
if (providedSubgraphHashFile && providedSubgraphHashFile.length > 0) {
subgraphHashPath = providedSubgraphHashFile;
} else if (envSubgraphHashFile && envSubgraphHashFile.length > 0) {
subgraphHashPath = envSubgraphHashFile;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for determining subgraphHashPath by prioritizing the CLI option over the environment variable is more verbose than necessary. This can be simplified into a single line using the logical OR (||) operator, which improves readability and conciseness. The subgraphHashFileOption is already a trimmed string or undefined from the command's action handler, so no further processing is needed on it.

Suggested change
const envSubgraphHashFile = Bun.env.SUBGRAPH_HASH_FILE?.trim();
const providedSubgraphHashFile =
subgraphHashFileOption === undefined
? undefined
: subgraphHashFileOption.trim();
let subgraphHashPath: string | undefined;
if (providedSubgraphHashFile && providedSubgraphHashFile.length > 0) {
subgraphHashPath = providedSubgraphHashFile;
} else if (envSubgraphHashFile && envSubgraphHashFile.length > 0) {
subgraphHashPath = envSubgraphHashFile;
}
const subgraphHashPath =
subgraphHashFileOption || Bun.env.SUBGRAPH_HASH_FILE?.trim();

@roderik roderik merged commit cd6ef11 into main Sep 21, 2025
13 checks passed
@roderik roderik deleted the codex/add-subgraph_hash-env-var-for-config-map branch September 21, 2025 07:42
@github-actions github-actions Bot added status:merged Pull request has been merged and removed status:ready-for-review Pull request is ready for review labels Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex feat New feature qa:success QA workflow passed successfully status:merged Pull request has been merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant