{"record":{"id":"941d1e0fe7e92515","repo":"mattermost-community/focalboard","slug":"card-limit-value-is-invalid","errorCode":null,"errorMessage":"card limit value is invalid","messagePattern":"card limit value is invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/services/store/sqlstore/cloud.go","lineNumber":16,"sourceCode":"// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n// See LICENSE.txt for license information.\n\npackage sqlstore\n\nimport (\n\t\"database/sql\"\n\t\"errors\"\n\t\"strconv\"\n\n\tsq \"github.com/Masterminds/squirrel\"\n\t\"github.com/mattermost/focalboard/server/model\"\n\t\"github.com/mattermost/focalboard/server/services/store\"\n)\n\nvar ErrInvalidCardLimitValue = errors.New(\"card limit value is invalid\")\n\n// activeCardsQuery applies the necessary filters to the query for it\n// to fetch an active cards window if the cardLimit is set, or all the\n// active cards if it's 0.\nfunc (s *SQLStore) activeCardsQuery(builder sq.StatementBuilderType, selectStr string, cardLimit int) sq.SelectBuilder {\n\tquery := builder.\n\t\tSelect(selectStr).\n\t\tFrom(s.tablePrefix + \"blocks b\").\n\t\tJoin(s.tablePrefix + \"boards bd on b.board_id=bd.id\").\n\t\tWhere(sq.Eq{\n\t\t\t\"b.delete_at\":    0,\n\t\t\t\"b.type\":         model.TypeCard,\n\t\t\t\"bd.is_template\": false,\n\t\t})\n\n\tif cardLimit != 0 {\n\t\tquery = query.\n\t\t\tLimit(1).","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/mattermost-community/focalboard/blob/a84bbb65e32edf972856b329417096ac413518e9/server/services/store/sqlstore/cloud.go#L1-L34","documentation":"ErrInvalidCardLimitValue indicates the card limit timestamp stored in the system_settings table is not a valid integer. getCardLimitTimestamp reads the value and returns this sentinel when strconv.Atoi fails. The library throws it so callers know the cloud card-limit feature cannot determine the cutoff timestamp.","triggerScenarios":"Reading getCardLimitTimestamp when the CardLimitTimestamp system_settings row contains a non-numeric string (corrupted write, manual edit, or value written by incompatible code).","commonSituations":"Manual DB manipulation of system_settings, restore from a backup with a stale/mangled row, or a bug writing the setting as a formatted string instead of an integer.","solutions":["Reset the card_limit_timestamp row in system_settings to '0' (or delete the row; missing rows default to 0).","Call updateCardLimitTimestamp to have the server recompute and store a valid value.","Audit any scripts/tools that write to system_settings and ensure they store plain integers.","Check errors.Is(err, ErrInvalidCardLimitValue) and fall back to card-limit-disabled behavior."],"exampleFix":"-- before: corrupted value\nSELECT value FROM system_settings WHERE id='card_limit_timestamp'; -- 'abc'\n-- after\nUPDATE system_settings SET value='0' WHERE id='card_limit_timestamp';","handlingStrategy":"try-catch","validationCode":"// verify stored setting is numeric before relying on it\nrow, _ := db.Query(\"SELECT value FROM system_settings WHERE id='CardLimitTimestamp'\")\nvar v string\n_ = row.Scan(&v)\nif _, err := strconv.Atoi(v); err != nil {\n    // reset to 0\n    db.Exec(\"UPDATE system_settings SET value='0' WHERE id='CardLimitTimestamp'\")\n}","typeGuard":"func isIntString(s string) bool {\n    _, err := strconv.Atoi(s)\n    return err == nil\n}","tryCatchPattern":"ts, err := store.GetCardLimitTimestamp()\nif errors.Is(err, sqlstore.ErrInvalidCardLimitValue) {\n    log.Warn(\"corrupt card limit timestamp; card limit disabled\")\n    ts = 0\n}","preventionTips":["Never hand-edit the system_settings table.","Write the card limit setting only through the server API.","Restore-with-validation after DB restores.","Fall back to 0 (limit disabled) on parse failure."],"tags":["go","database","cloud-limits"],"backgroundTag":"invalid-setting-value","analyzedSha":"a84bbb65e32edf972856b329417096ac413518e9","analyzedAt":"2026-08-30T09:22:20.720Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}