Skip to content

Conversation

@gocanto
Copy link
Collaborator

@gocanto gocanto commented Oct 13, 2025

Summary

  • add build-tag helpers to report CGO availability from the SEO generator
  • expand debug logging and contextual error propagation throughout the generation steps

Testing

  • go test ./metal/... (fails: command hung waiting for external dependencies)

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

Summary by CodeRabbit

  • New Features

    • WebP image encoding is now supported when CGO is available.
    • CLI output provides more detailed progress and error context during SEO generation.
  • Improvements

    • Faster repeated SEO data retrieval via caching of profile, projects, and recommendations.
    • More robust generation flow with clearer error messages across pages and posts.
  • Chores

    • Build and runtime configuration updated to enable CGO in local and containerized environments.

@gocanto gocanto marked this pull request as draft October 13, 2025 08:11
@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the primary change by indicating improvements to diagnostics in the SEO generator, aligns with the PR description’s focus on enhanced logging and contextual error reporting, and follows a single-sentence, conventional commit style without extraneous detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gus/fix-metal/cli/seo/generator.go-on-ubuntu-2025-10-13

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @gocanto, 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 significantly enhances the diagnostic capabilities of the SEO generator. It introduces a mechanism to explicitly report the CGO availability status, which is vital for understanding environment-specific behaviors. Furthermore, it integrates comprehensive debug logging across the entire SEO generation pipeline and refines error handling by providing contextual information with each propagated error, thereby streamlining the debugging process and improving overall system observability.

Highlights

  • CGO Availability Reporting: Introduced build-tag helpers to report whether CGO (C-language bindings for Go) is enabled or disabled within the SEO generator, providing crucial diagnostic information.
  • Enhanced Debug Logging: Expanded debug logging throughout the SEO generation process, including initialization, pipeline start/end, and detailed steps for fetching data for various pages (Index, About, Projects, Resume, Posts).
  • Contextual Error Propagation: Improved error handling by wrapping errors with contextual information at each generation step, making it easier to trace the origin of failures and understand the error's context.
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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.

Copy link

@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 successfully improves the diagnostics for the SEO generator by adding more detailed logging and wrapping errors to provide better context. The use of build tags to report CGO availability is a good addition. The changes are well-aligned with the stated goals. I have added a couple of suggestions to enhance maintainability and performance by refactoring some repetitive code and caching data to avoid redundant fetches.

@gocanto gocanto changed the title Improve SEO generator diagnostics fix: Improve SEO generator diagnostics Oct 13, 2025
@gocanto gocanto added testing and removed codex labels Oct 13, 2025
@gocanto
Copy link
Collaborator Author

gocanto commented Oct 13, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

@gocanto gocanto marked this pull request as ready for review October 13, 2025 09:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose.yml (1)

93-99: Enable CGO at build time via build‐arg
The API Dockerfile installs CGO deps but doesn’t accept CGO_ENABLED—add:

  • In docker/dockerfile-api:
    ARG CGO_ENABLED
    ENV CGO_ENABLED=${CGO_ENABLED}
  • In docker-compose.yml under the api service’s build.args:
    build:
      args:
        - CGO_ENABLED=1
♻️ Duplicate comments (1)
metal/cli/seo/generator.go (1)

15-16: Breaks non‑CGO builds; split CGO detection via build tags and remove runtime/cgo import

Blank‑importing runtime/cgo and hardcoding cgoEnabled = true forces CGO and fails when CGO_ENABLED=0 (compiler excludes runtime/cgo). This contradicts “report CGO availability” and removes the pure‑Go path. Use build‑tagged files to set cgoEnabled instead.

Apply within this file:

-	_ "runtime/cgo"
-
...
-const cgoEnabled = true

Add new files:

cgo_enabled.go

//go:build cgo

package seo

import _ "runtime/cgo" // ensures presence when built with CGO
const cgoEnabled = true

cgo_disabled.go

//go:build !cgo

package seo

const cgoEnabled = false

The existing fmt.Printf("CGO enabled: %t", cgoEnabled) will now accurately reflect build mode without breaking pure‑Go builds.

Also applies to: 28-28

🧹 Nitpick comments (3)
Makefile (1)

32-32: Don’t force CGO globally; make it overridable or scope per target

.EXPORT_ALL_VARIABLES plus CGO_ENABLED := 1 forces CGO for all commands, which can break cross-compiles or environments lacking a C toolchain. Prefer a default that users can override, or set per build targets.

Apply:

-CGO_ENABLED           := 1
+CGO_ENABLED           ?= 1

Optionally scope CGO to build targets only:

build-local build-ci build-release: export CGO_ENABLED=1
metal/cli/seo/client.go (2)

57-65: Nice: per-entity caching via sync.Once reduces repeated IO

The lazy, once-per-entity fetch is clean and thread-safe. Good alignment with generator usage.

Note: sync.Once also caches the first error permanently (no retries). If transient errors are possible, consider:

  • a ResetCache() to clear c.data between runs/tests, or
  • using singleflight.Group to dedupe concurrent calls but allow subsequent retries.

Example ResetCache:

// Add to Client
func (c *Client) ResetCache() { c.data = ClientData{} }

Use cautiously only when no concurrent reads are in-flight.

Also applies to: 68-75, 83-91


20-32: Avoid exposing cache internals; make ClientData unexported

ClientData leaks internal caching details into the public API. Make it unexported (clientData) to preserve flexibility.

-type ClientData struct {
+type clientData struct {
   // ...
 }
 
 type Client struct {
   WebsiteRoutes *router.WebsiteRoutes
   Fixture       router.Fixture
-  data          ClientData
+  data          clientData
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 361e5c6 and f7341fd.

📒 Files selected for processing (5)
  • Makefile (1 hunks)
  • docker-compose.yml (2 hunks)
  • metal/cli/seo/client.go (4 hunks)
  • metal/cli/seo/generator.go (9 hunks)
  • pkg/images/webp_encode_stub.go (0 hunks)
💤 Files with no reviewable changes (1)
  • pkg/images/webp_encode_stub.go
🧰 Additional context used
🧬 Code graph analysis (2)
metal/cli/seo/generator.go (4)
pkg/cli/message.go (2)
  • Magentaln (33-35)
  • Cyanln (49-51)
metal/cli/seo/categories.go (1)
  • NewCategories (16-21)
metal/cli/seo/client.go (1)
  • Client (14-18)
metal/cli/seo/sections.go (1)
  • NewSections (14-16)
metal/cli/seo/client.go (8)
handler/payload/profile.go (1)
  • ProfileResponse (3-6)
handler/payload/projects.go (1)
  • ProjectsResponse (3-6)
handler/payload/recommendations.go (1)
  • RecommendationsResponse (3-6)
metal/router/static.go (1)
  • StaticRouteResource (10-12)
handler/profile.go (1)
  • MakeProfileHandler (16-20)
metal/router/fixture.go (1)
  • Fixture (15-20)
handler/projects.go (1)
  • MakeProjectsHandler (16-20)
handler/recommendations.go (1)
  • MakeRecommendationsHandler (16-20)
🔇 Additional comments (1)
metal/cli/seo/generator.go (1)

96-111: Good refactor: step pipeline simplifies flow and error context

The loop removes repetition and standardizes contextual error wrapping. Nice.

@gocanto gocanto merged commit 53f023a into main Oct 13, 2025
5 checks passed
@gocanto gocanto deleted the gus/fix-metal/cli/seo/generator.go-on-ubuntu-2025-10-13 branch October 13, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants