Skip to content

Send file contents directly when counting lines of code - #13106

Merged
iHiD merged 2 commits into
mainfrom
count-lines-of-code-without-efs
Nov 18, 2026
Merged

iHiD merged 2 commits into
mainfrom
count-lines-of-code-without-efs

Conversation

@iHiD

@iHiD iHiD commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Currently, counting an iteration's lines of code copies its files to EFS, posts their paths to the lines-of-code counter, and then deletes them from EFS. This PR makes Iteration::CountLinesOfCode post the file contents instead:

{"track_slug": "ruby", "files": {"lib/bob.rb": "<file content as a UTF-8 string>"}}

The response format is the same, and the retry on 502, 503 and 504 is unchanged. The EFS upload, the EFS delete and the job_dir and efs_dir helpers are removed from this command. Other tooling jobs still use EFS.

If a file's content isn't valid UTF-8, it can't be sent as a JSON string, and Submission::File#content would return the placeholder "[Invalid Unicode]", which the counter would count as a line of code. This command leaves such files out of the request. If no valid UTF-8 files remain, it doesn't call the counter, which matches how it already behaves for a submission with no valid files.

The counter runs as a Lambda behind an ALB, which rejects request bodies over 1 MB with a 413. If the JSON body is over MAX_BODY_BYTES (1,000,000 bytes), the command returns without calling the counter or setting num_loc, as it does when there are no valid files. Other errors, such as a 400, still raise.

Do not merge until the counter change is deployed. The counter (exercism/lines-of-code-counter) is getting a PR that accepts both the old and the new format. This PR must only be merged after that has been deployed, or the counter will reject the new requests.

Tests: bin/rails test test/commands/iteration/count_lines_of_code_test.rb (13 runs, 0 failures).

🤖 Generated with Claude Code

iHiD and others added 2 commits November 17, 2026 23:31
Iteration::CountLinesOfCode no longer copies the submission's files to
EFS. It posts each valid file's content to the counter as JSON instead.
Files that aren't valid UTF-8 are left out of the request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The counter sits behind an ALB that rejects bodies over 1 MB with a 413,
so the command now returns without calling it if the body is too big.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iHiD
iHiD merged commit 228147b into main Nov 18, 2026
31 checks passed
@iHiD
iHiD deleted the count-lines-of-code-without-efs branch November 18, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant