Repository navigation
Conversation
alexandria and betamax removed their v1 endpoints on 16 Nov, so the fallback could only end in a 404. API v2 is now the only upload path. Api::V2Client.require_service_token! refuses any token but robles's kst_ token before a request, with a TokenError that says which variable and which Actions secrets to fix, and never includes the token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012zKenG3Uv4daWuHUSyQ3qi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: WEB-8371 (part of WEB-7849, API v2 phase 3)
alexandria and betamax removed their v1 endpoints on 16 Nov, so robles's fallback to v1 for a non-
kst_token could only end in a 404 that didn't say the token was the problem. This deletes the fallback. API v2 is the only upload path, and a wrong or missing token now fails before any request, with a message that says what to fix.What changed
No files removed.
Code paths deleted
book_uploader.rb:PUBLISH_URL, the v1 post,api_uri,connandinclude Util::Logging(onlyconnused it).content_module_uploader.rb:PUBLISH_URL,OPEN_TIMEOUT/READ_TIMEOUT, the v1 post with itsrescue Faraday::Error, the v1 log helpers (log_upload_start/success/failure,monotonic_now,elapsed_since),api_uriandconn.include Util::Loggingstays for the v2 log line.video_course_uploader.rb:UPLOAD_URL, the v1 post,api_uriandconn.upload_with_api_v2is folded intouploadin all three. The module's log line still comes before the post, and the video course's after it.Added
Api::V2Client::TokenError < StandardErrorandApi::V2Client.require_service_token!(token, name:, service:). Each uploader calls it first. It isn't anApi::V2Client::Error, because no request is made; the runner'srescue StandardErrorstill sends the Slack failure notice. The message (alexandria; betamax is the same with its names):It never includes the token, and empty and wrong tokens get the same message.
Comments reworded where they described v1 as live: the three uploaders,
v2_client.rb(the switch comment and the timeout comment that pointed at the deleted constants),config/initialisers/alexandria.rband.env.sample.Kept:
ALEXANDRIA_SERVICE_API_TOKEN/BETAMAX_SERVICE_API_TOKEN(not renamed), thetoken:andclient:keywords,V2_PUBLISH_PATH,V2_UPLOAD_PATH,V2_TIMEOUT, thepayloadmethods andservice_token?.Tests
stub_v1(all three),assert_v1_upload(video), the v1 tests (book 3, module 3, video 2) andtest_kst_token_never_builds_v1(book, module).test_kst_token_timeout_skips_v1_rescue→test_kst_token_timeout(asserts anApi::V2Client::ErrornamingFaraday::TimeoutError); videotest_kst_token_logs_and_never_builds_v1→test_kst_token_logs(@connassertion dropped); videov1_body→upload_body;UnusedClientcomments reworded.test_shared_token_is_refusedandtest_no_token_is_refusedin each uploader test, through a sharedassert_token_refusedhelper intest/support/v2_client_stubs.rb(asserts aTokenError, that the message names the variable and both secrets, and that it doesn't contain the token);test_require_service_tokeninv2_client_test.rb(KST_TOKENpasses;nil,'', the shared token and an upper-caseKST_token raise).Size: non-test +53 / −171, test +60 / −126. No Gemfile, workflow or config change.
How I verified it
bin/test: 215 runs, 0 failures (run in a Debianruby:4.0.9container, since the Alpine image's packages can't be fetched here).bin/rubocop: no offences.bundle-audit check --update: only the 7 existing puma 8.0.2 advisories. The bundler-audit job on this PR is red for that reason, not because of this change. Bump puma to 8.0.4 for bundler-audit #359 bumps puma and fixes it; once it merges,developmentwill be merged into this branch.git grep -n -E "/api/(editions|content_modules)/publish|/api/v1/|PUBLISH_URL|UPLOAD_URL|api_uri|def conn|stub_v1|v1_requests|_uses_v1|never_builds_v1" -- app test config .env.samplegit grep -n "uses v1" -- app config .env.sampleOut of scope
secretscommand andREPO_*variables), and WEB-8365 to WEB-8370 and WEB-8372.release-v1books, and therelease-v1image.faraday-retrygem.Rollout
developmentrebuilds:staging, which every staging workflow uses from its next run. Then run one book and one module staging workflow and check the log forApi::V2Client POST /api/v2/... 201and Slack success (withENV=staginga failed run still exits 0).api_v2_auditlines from callerrobles, by status, for 7 days).development; if released, release the revert as a patch.Generated by Claude Code