Skip to content

Python seed comments bypass dictionary validation and translation #70617

Open
notsoravii/freeCodeCamp
#6

Description

@majestic-owl448

Python seed comments bypass dictionary validation and translation. translateComments handles js, jsx, and html, but py falls through to the default branch and returns the source unchanged.

exports.translateComments = (text, lang, dict, codeLang) => {
const knownComments = Object.keys(dict);
const config = { knownComments, dict, lang };
const input = { text };
switch (codeLang) {
case 'js':
case 'jsx':
return transMultiline(transInline(input, config), config);
case 'html':
return transScript(transHTML(transCSS(input, config), config), config);
default:
return input;
}
};

I reproduced both behaviors from the repository root:

const { translateComments } = require('./tools/challenge-parser/translation-parser');
const dict = { 'Example comment': { spanish: 'Comentario de ejemplo' } };

translateComments('# Example comment', 'spanish', dict, 'py');
// Returns { text: '# Example comment' }, ignoring the translation.

translateComments('# Unregistered comment', 'spanish', {}, 'py');
// Returns the source unchanged without an error.

With js and // comments, the same calls translate the registered comment and throw for the unregistered comment.

The ISBN validator lab provides an existing example: none of its 15 seed-comment occurrences are registered in either curriculum/dictionaries/english/comments.json or curriculum/dictionaries/english/comments-to-not-translate.json.

# Calculate the check digit from other digits
if length == 10:
expected_check_digit = calculate_check_digit_10(main_digits_list)
else:
expected_check_digit = calculate_check_digit_13(main_digits_list)
# Check if the given check digit matches with the calculated check digit
if given_check_digit == expected_check_digit:
print('Valid ISBN Code.')
else:
print('Invalid ISBN Code.')
def calculate_check_digit_10(main_digits_list):
# Note: You don't have to fully understand the logic in this function.
digits_sum = 0
# Multiply each of the first 9 digits by its corresponding weight (10 to 2) and sum up the results
for index, digit in enumerate(main_digits_list):
digits_sum += digit * (10 - index)
# Find the remainder of dividing the sum by 11, then subtract it from 11
result = 11 - digits_sum % 11
# The calculation result can range from 1 to 11.
# If the result is 11, use 0.
# If the result is 10, use upper case X.
# Use the value as it is for other numbers.

Both dictionaries are loaded into the comment map, so the second registry does not account for these comments.

const COMMENTS_TO_TRANSLATE = JSON.parse(
readFileSync(resolve(dictionariesDir, 'english', 'comments.json'), 'utf8')
) as Record<string, string>;
const COMMENTS_TO_NOT_TRANSLATE = JSON.parse(
readFileSync(
resolve(dictionariesDir, 'english', 'comments-to-not-translate.json'),
'utf8'
)
) as Record<string, string>;
// map from english comment text to translations
const translatedCommentMap = Object.entries(COMMENTS_TO_TRANSLATE).reduce(
(acc, [id, text]) => {
return {
...acc,
[text]: getTranslationEntry(dictionaries, { engId: id, text })
};
},
{} as CommentDictionary
);
// map from english comment text to itself
const untranslatableCommentMap = Object.values(
COMMENTS_TO_NOT_TRANSLATE
).reduce((acc, text) => {
const englishEntry = languages.reduce(
(acc, lang) => ({
...acc,
[lang]: text
}),
{}
);
return {
...acc,
[text]: englishEntry
};
}, {} as CommentDictionary);
const allComments = { ...translatedCommentMap, ...untranslatableCommentMap };

Activity

  1. added
    scope: curriculum
    status: waiting triage
    scope: i18n
    scope: tools/scripts
    python v9 cert
    on Oct 4, 2026
  2. majestic-owl448 commented on Oct 4, 2026

    @majestic-owl448
    ContributorAuthor

    This also happens for comments in css, ts and tsx files

  3. locked and limited conversation to collaborators on Oct 5, 2026
  4. removed
    status: waiting triage
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    python v9 certscope: curriculumscope: i18nscope: tools/scripts

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions