Story: LinkedIn Scheduling Fix
Status
done
Story
As a user, I want scheduled LinkedIn posts to actually publish when the scheduled time arrives, so that my scheduled content is automatically posted to LinkedIn without requiring manual intervention.
Acceptance Criteria
- Scheduled LinkedIn posts execute at the specified time
- The scheduled post follows the same workflow as manual "generate then publish"
- The system provides clear feedback when scheduling fails
- Existing manual publishing functionality continues to work unchanged
- Integration with LinkedIn API maintains current behavior
- Change is covered by appropriate tests (scheduler execution tests)
- Error logging is updated to capture scheduling failures
- No regression in existing manual publishing functionality
Tasks / Subtasks
- Investigate why scheduled LinkedIn posts are not executing
- Examine scheduler job execution path
- Compare with manual publish execution path
- Check authentication token handling for scheduled jobs
- Fix scheduler execution to match manual publish flow (AC: #1, #2)
- Update scheduler to use same posting workflow as manual publish
- Ensure proper authentication context for scheduled jobs
- Update error logging to capture scheduling failures (AC: #3, #7)
- Add specific logging for LinkedIn scheduler jobs
- Ensure errors are visible in logs
- Verify manual publishing continues to work (AC: #4, #8)
- Test manual publish functionality after changes
- Ensure no regression in existing functionality
- Add/update tests for scheduler functionality (AC: #6)
- Create tests for LinkedIn scheduler execution
- Verify existing manual publish tests still pass
Dev Notes
This story addresses an issue where scheduled LinkedIn posts are not being published, while manual "generate then publish" functionality works correctly. The scheduler likely creates a job that doesn't properly execute the same posting workflow as the manual function.
The fix should ensure that the scheduler uses the same execution pathway as the manual publish flow, paying special attention to authentication token handling which may differ between immediate execution (manual) and delayed execution (scheduled).
Testing
List Relevant Testing Standards from Architecture the Developer needs to conform to:
- Test file location: tests/scheduler_tests.py
- Test standards: Follow existing pytest patterns in the codebase
- Testing frameworks and patterns to use: pytest with proper mocking for LinkedIn API calls
- Any specific testing requirements for this story: Need to test both successful scheduling and error handling scenarios
Change Log
| Date | Version | Description | Author |
|---|---|---|---|
| 2025-11-21 | 1.0 | Initial story creation | Product Manager |
Dev Agent Record
Agent Model Used
Qwen
Debug Log References
backend/logs/app.log, backend/logs/scheduler.log
Completion Notes List
- Fixed scheduler execution context issue where LinkedInService was not properly initialized due to missing Flask application context
- Enhanced error logging with detailed tracebacks for debugging scheduler issues
- Added comprehensive tests for scheduler functionality
- Verified that manual publishing functionality remains unchanged
- Updated LinkedIn posting to run within proper Flask application context
File List
- backend/scheduler/apscheduler_service.py
- backend/tests/scheduler_tests.py