Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/ai/backend/install/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,43 @@ async def etcd_get_json(self, key: str) -> Any:

async def install_halfstack(self) -> None:
self.log_header("Installing halfstack...")

self.log_header("Generating supergraph.graphql via rover CLI...")

compose_cmd = [
"rover",
"supergraph",
"compose",
"--config",
"configs/graphql/supergraph.yaml",
]
output_path = "docs/manager/graphql-reference/supergraph.graphql"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The output path is a relative string path that depends on the current working directory. This could fail if the script is not run from the expected project root. Consider using project_root / output_path to make it absolute and consistent with the later file operations.

Suggested change
output_path = "docs/manager/graphql-reference/supergraph.graphql"
project_root = Path(__file__).resolve().parents[4]
output_path = project_root / "docs/manager/graphql-reference/supergraph.graphql"

Copilot uses AI. Check for mistakes.

proc = await asyncio.create_subprocess_exec(
*compose_cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
raise RuntimeError(f"Failed to compose supergraph schema:\n{stderr.decode()}")
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The error message could be more informative by including the command that failed. Consider changing to: raise RuntimeError(f\"Failed to compose supergraph schema using rover CLI:\n{stderr.decode()}\") to make troubleshooting easier.

Suggested change
raise RuntimeError(f"Failed to compose supergraph schema:\n{stderr.decode()}")
raise RuntimeError(
f"Failed to compose supergraph schema using rover CLI.\n"
f"Command: {' '.join(compose_cmd)}\n"
f"Error output:\n{stderr.decode()}"
)

Copilot uses AI. Check for mistakes.
with open(output_path, "wb") as f:
f.write(stdout)
Comment on lines +287 to +288
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Using synchronous file I/O in an async function. Since aiofiles is already imported in this file (line 23), consider using async with aiofiles.open(output_path, 'wb') as f: await f.write(stdout) for consistency with the async context and to avoid blocking the event loop.

Suggested change
with open(output_path, "wb") as f:
f.write(stdout)
async with aiofiles.open(output_path, "wb") as f:
await f.write(stdout)

Copilot uses AI. Check for mistakes.
self.log_header(f"Wrote supergraph schema to {output_path}")

base_path = self.install_info.base_path
project_root = Path(__file__).resolve().parents[4]
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Using magic number [4] to traverse parent directories is fragile and depends on the exact file structure. If the file is moved or the directory structure changes, this will break. Consider using a more robust approach like searching for a marker file (e.g., 'BUILD_ROOT') or defining the project root explicitly in the context.

Copilot uses AI. Check for mistakes.

src_gateway = project_root / "configs/graphql/gateway.config.ts"
dst_gateway = base_path / "gateway.config.ts"
shutil.copy2(src_gateway, dst_gateway)
self.log_header(f"Copied {src_gateway} -> {dst_gateway}")

src_supergraph = project_root / "docs/manager/graphql-reference/supergraph.graphql"
dst_supergraph = base_path / "supergraph.graphql"
shutil.copy2(src_supergraph, dst_supergraph)
self.log_header(f"Copied {src_supergraph} -> {dst_supergraph}")

dst_compose_path = self.copy_config("docker-compose.yml")
self.copy_config("prometheus.yaml")
self.copy_config("grafana-dashboards")
Expand Down
Loading