Common Issues and Solutions
API Connection Failures
Symptom
Your generated story shows “Error” as the title or “Fallo al conectar con la API” as the content.Error Handling in Code
The script includes basic error handling:Possible Causes and Solutions
Solution:- Verify your API key is correctly set in GitHub Secrets
- Go to your repository → Settings → Secrets and variables → Actions
- Check that
OPENROUTER_API_KEYexists and contains a valid key - Get a new API key from OpenRouter if needed
- Check OpenRouter status page for API outages
- GitHub Actions may have temporary network issues - wait and retry
- Free tier models have usage limits
- Check your OpenRouter dashboard for quota information
- Consider upgrading or using a different model
To debug API responses, you can temporarily add
print(response.text) after line 24 in generar_historia.py to see the raw response in GitHub Actions logs.GitHub Actions Not Running
Symptom
The workflow doesn’t execute automatically at the scheduled time.Scheduled Execution Details
The workflow is configured to run daily:Common Causes
1. Repository Inactivity Solution:- Make any commit to the repository
- Or manually trigger the workflow using the “Actions” tab
- GitHub will send you an email warning before disabling
- Go to the “Actions” tab in your repository
- Click on “Actualizar Historia Diaria” workflow
- If you see “This workflow was disabled”, click “Enable workflow”
0 13 * * *= Every day at 13:00 UTC (8:00 AM Lima time)
Scheduled workflows may be delayed by up to 10-15 minutes during high-load periods on GitHub’s infrastructure. This is normal behavior.
Secret Configuration Errors
Symptom
Workflow fails with authentication errors or the API key appears empty.How Secrets Work
The workflow accesses the secret like this:Common Mistakes
Secret Name Mismatch:- Secret must be named exactly
OPENROUTER_API_KEY - Secret names are case-sensitive
- Secrets must be set in Repository Settings, not Environment secrets
- Path: Settings → Secrets and variables → Actions → Repository secrets
- Copy the API key carefully without extra spaces
- GitHub Secrets trim spaces, but verify the key is correct
File Permission Issues
Symptom
Workflow fails with “Permission denied” or “failed to push some refs”.Required Permissions
The workflow needs write access:Solutions
1. Enable Workflow Permissions- Go to Settings → Actions → General
- Scroll to “Workflow permissions”
- Select “Read and write permissions”
- Check “Allow GitHub Actions to create and approve pull requests” (optional)
- Click “Save”
main:
- Workflows may not be able to push directly
- Either disable branch protection or allow Actions to bypass
Invalid API Responses
Symptom
Stories are generated but titles or content are missing or malformed.Response Parsing Logic
The script uses regex to extract content:Common Issues
AI Doesn’t Follow Format: The AI model sometimes ignores the prompt format. Fallback Values:- If
<TITULO>tags not found: “Historia sin título” - If
<HISTORIA>tags not found: “Error al generar la historia.”
-
Try a different model - Edit line 23 in
generar_historia.py: - Strengthen the prompt - The prompt at lines 11-17 can be made more explicit
-
Add validation logging - Temporarily add debugging:
History JSON Corruption
Symptom
The sidebar menu doesn’t appear or shows broken links.How History Works
The script maintainshistorial.json:
Expected JSON Format
Fixing Corruption
Solution 1: Manual Fix- Open
historial.jsonin your repository - Click “Edit”
- Fix JSON syntax errors (use a JSON validator)
- Commit changes
- Delete
historial.jsonfrom your repository - The script will create a fresh one on next run
- Previous stories will still exist as HTML files
- You’ll need to manually rebuild the history or let it accumulate
- Don’t manually edit
historial.jsonunless you’re comfortable with JSON - Use a JSON validator before committing changes
Template Rendering Errors
Symptom
Generated HTML pages show placeholders like{{TITULO}} instead of actual content.
Template Variables
The script replaces these placeholders inplantilla.html:
Common Causes
Missingplantilla.html:
- The template file must exist in the repository root
- Check line 85:
with open('plantilla.html', 'r', encoding='utf-8') as archivo:
plantilla.html exists and contains:
{{TITULO}}- Story title{{HISTORIA}}- Story content{{IMAGEN_URL}}- Image URL{{MENU}}- Sidebar menu HTML
Dependency Installation Failures
Symptom
Workflow fails at the “Instalar dependencias” step.Installation Steps
Solutions
Network Timeouts:- Retry the workflow (usually temporary)
- GitHub Actions has reliable PyPI connectivity
'3.11' or '3.12'.
Additional Dependencies:
The script only requires:
requests(for API calls)json,re,datetime,uuid,os(all built-in)
Debugging Tips
Viewing Workflow Logs
- Go to your repository on GitHub
- Click the “Actions” tab
- Click on a workflow run (green check, red X, or yellow dot)
- Click on the job name “generar-pagina”
- Expand each step to see detailed output
Testing Locally
You can test the script on your computer:Local testing requires
plantilla.html in the same directory.Manual Workflow Trigger
Test without waiting for the schedule:- Go to Actions tab
- Click “Actualizar Historia Diaria”
- Click “Run workflow” button
- Select branch (usually
main) - Click “Run workflow”
Getting Help
If you’re still experiencing issues:- Check workflow logs for specific error messages
- Verify all secrets are correctly configured
- Test the API key separately using curl or Postman
- Review recent commits that might have introduced changes
- Check GitHub Status at githubstatus.com
Most issues are related to API keys or GitHub Actions permissions. Double-check these first!