<commit_before>'use strict';

/* Modules */
var imageSets = require('cloud/imagesets.js').ImageSets;

/**
 * Responds with the next image set.
 * @param request.params.id The current image set id.
 */
Parse.Cloud.define('getNextImageSet', function(request, response) {
    var id = parseInt(request.params.id, 10);
    var nextId = isNaN(id) ? 0 : (id + 1) % imageSets.length;
    var imageSet = imageSets[nextId];
    response.success(imageSet);
});<commit_msg>Handle invalid image set ids in api code<commit_after>'use strict';

/* Modules */
var imageSets = require('cloud/imagesets.js').ImageSets;

/**
 * Responds with the next image set.
 * @param request.params.id The current image set id.
 */
Parse.Cloud.define('getNextImageSet', function(request, response) {
    var id = parseInt(request.params.id, 10);
    var nextId = (isNaN(id) || id < 0 || id >= imageSets.length) ? 0 : (id + 1) % imageSets.length;
    var imageSet = imageSets[nextId];
    response.success(imageSet);
});
{'fraction_non_alphanumeric': 0.15166835187057634, 'fraction_numerical': 0.00910010111223458, 'mean_word_length': 4.025380710659898, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '302125', 'n_tokens_mistral': 324, 'n_tokens_neox': 314, 'n_words': 85}