)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"08b8ec295e0360f2f82a8863a56e8f6cb6bf8959","unresolved":true,"context_lines":[{"line_number":15,"context_line":"broker, so existing usage of `swift-manage-shard-ranges"},{"line_number":16,"context_line":"\u003cshard-data.json\u003e analyze` is unchanged. The input type is explicit"},{"line_number":17,"context_line":"rather than inferred by first trying to open the file as a DB, because"},{"line_number":18,"context_line":"opening a broker is not side-effect free: a JSON input could have its"},{"line_number":19,"context_line":"directory quarantined as a corrupt DB, and a JSON file with the same"},{"line_number":20,"context_line":"hash name as a DB would be shadowed by that DB."},{"line_number":21,"context_line":""},{"line_number":22,"context_line":"Assisted-By: Codex:gpt-5"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fc4df3f5_98176118","line":19,"range":{"start_line":18,"start_character":42,"end_line":19,"end_character":37},"updated":"2026-11-11 10:09:11.000000000","message":"is this true now that we have ``quarantine_ok \u003d False``?","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[{"line_number":15,"context_line":"broker, so existing usage of `swift-manage-shard-ranges"},{"line_number":16,"context_line":"\u003cshard-data.json\u003e analyze` is unchanged. The input type is explicit"},{"line_number":17,"context_line":"rather than inferred by first trying to open the file as a DB, because"},{"line_number":18,"context_line":"opening a broker is not side-effect free: a JSON input could have its"},{"line_number":19,"context_line":"directory quarantined as a corrupt DB, and a JSON file with the same"},{"line_number":20,"context_line":"hash name as a DB would be shadowed by that DB."},{"line_number":21,"context_line":""},{"line_number":22,"context_line":"Assisted-By: Codex:gpt-5"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"1ee7eb5c_f7b6c7fd","line":19,"range":{"start_line":18,"start_character":42,"end_line":19,"end_character":37},"in_reply_to":"fc4df3f5_98176118","updated":"2026-11-13 23:23:12.000000000","message":"It is not, this was proposed before that change was made. I will rebase before the next iteration of the patch.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":true,"context_lines":[{"line_number":24,"context_line":"example, \u003chash\u003e.json could be shadowed by \u003chash\u003e.db. Stating the user\u0027s"},{"line_number":25,"context_line":"intent keeps this simple: analyze only needs to reject an existing file"},{"line_number":26,"context_line":"that a broker would not open itself, with an error suggesting --json."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Assisted-By: Codex:gpt-5"},{"line_number":29,"context_line":"Assisted-By: Claude Code:claude-opus-5-5"},{"line_number":30,"context_line":"Change-Id: I55a9bd5ca63c0ece701714f76f8a6331198dfdd9"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"ba126f0c_74964d97","line":27,"updated":"2026-11-19 16:07:51.000000000","message":"please add an \n```UpgradeImpact```\ntag because of the change in default behaviour","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"25041048a9b3d1e3000e67b67bdf94bbd16876e5","unresolved":false,"context_lines":[{"line_number":24,"context_line":"example, \u003chash\u003e.json could be shadowed by \u003chash\u003e.db. Stating the user\u0027s"},{"line_number":25,"context_line":"intent keeps this simple: analyze only needs to reject an existing file"},{"line_number":26,"context_line":"that a broker would not open itself, with an error suggesting --json."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Assisted-By: Codex:gpt-5"},{"line_number":29,"context_line":"Assisted-By: Claude Code:claude-opus-5-5"},{"line_number":30,"context_line":"Change-Id: I55a9bd5ca63c0ece701714f76f8a6331198dfdd9"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"b9929892_4a6a8873","line":27,"in_reply_to":"ba126f0c_74964d97","updated":"2026-11-19 23:12:46.000000000","message":"Done","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"}],"/PATCHSET_LEVEL":[{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"e3cb338fe21e5c4cfb44a0764b219adfba47c99c","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"5010bdbb_5373d81e","updated":"2026-10-22 00:16:30.000000000","message":"I confirmed that this related patch resolves the quarantine issue: 1005958: db: Do not quarantine from operator-supplied paths | https://review.opendev.org/c/openstack/swift/+/1005958\n(though it does not fix the same-name db bug).\n\nI also proposed a fix for the bugs @matt@oliver.net.au identified by making the choice of json vs. db explicit: 1011793: sq: enable analyze command to open a db file with --db | https://review.opendev.org/c/openstack/swift/+/1011793","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"c5f3a3d51fe3ab07ffcd15ef43e62a4fe5662730","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"87911758_86252c10","updated":"2026-09-30 07:14:37.000000000","message":"I\u0027ll throw up a followup with some tests that show the json quaraitine faileure before I attempt to push a new patchset to fix it while Al isn\u0027t here.","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":6968,"name":"Christian Schwede","email":"cschwede@nvidia.com","username":"cschwede"},"change_message_id":"db13dbf5cc00b6150848ef7cf93809bcd0dd5569","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"11023e73_45380028","updated":"2026-10-06 11:02:01.000000000","message":"Simple SAIO reproducer for the issue reported by Matt:\n\n```\n$ mkdir -p ~/smsr/sda/containers/0/abc/hash\n$ python3 -c \"import json; from swift.common.utils import ShardRange; print(json.dumps([dict(ShardRange(\u0027a/c\u0027, 1))]))\" \u003e ~/smsr/sda/containers/0/abc/hash/shards.json\n$ swift-manage-shard-ranges ~/smsr/sda/containers/0/abc/hash/shards.json analyze\nContainerBroker: Quarantined /home/vagrant/smsr/sda/containers/0/abc/hash to /home/vagrant/smsr/sda/quarantined/containers/hash due to corrupted database\nFailed to open file /home/vagrant/smsr/sda/containers/0/abc/hash/shards.json: [Errno 2] No such file or directory: \u0027/home/vagrant/smsr/sda/containers/0/abc/hash/shards.json\u0027\n$ ls ~/smsr/sda/quarantined/containers\nhash\n\n```","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"c982bcbcc3a45bb921f7722ad0aaa0fb050e9812","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"fee24f82_a8c8a0bf","updated":"2026-10-01 04:48:57.000000000","message":"tests that demonstaight the issue is here: https://review.opendev.org/c/openstack/swift/+/1008195","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"08b8ec295e0360f2f82a8863a56e8f6cb6bf8959","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"a7893f63_b2727ab6","updated":"2026-11-11 10:09:11.000000000","message":"@Matthew, @Christian, apologies for showing up late to this review. You\u0027re more up to speed on the ins and outs of this, but can\u0027t we just assume JSON, catch a decode error and fall back opening as a broker? And with ``quarantine_ok`` we can try to open a broker safely.\n\nBTW, looks like this needs rebasing on master to pick up the ``quarantine_ok`` change.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":38368,"name":"Christian Ohanaja","display_name":"Christian Ohanaja","email":"cohanaja@nvidia.com","username":"cohanaja"},"change_message_id":"00ad759f0b6a39970b9532fb26c51e0175200923","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"b1159e94_1b23e285","updated":"2026-11-10 19:08:36.000000000","message":"Followup to use some header byte checking to detect if it\u0027s a db, still supports the `--db` + `--json` flags:\n\nhttps://review.opendev.org/c/openstack/swift/+/1014962","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"05b4143c_2edf00e4","updated":"2026-11-13 23:23:12.000000000","message":"I will update the patch with the results of the discussion.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"1671b8c5d0eb4073a9e390c49d3b2a578256bd83","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"11f74619_36ef60c4","updated":"2026-11-11 10:14:51.000000000","message":"Matthew Allen\n I\u0027d be very happy for you to claim authorship of this patch :) git commit --author\n \nIt\u0027s not really my work any more","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":38368,"name":"Christian Ohanaja","display_name":"Christian Ohanaja","email":"cohanaja@nvidia.com","username":"cohanaja"},"change_message_id":"06c53ae24df4c4798f2d6df59ab415c33e2a3a9a","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":5,"id":"3ccb87c1_862e1416","updated":"2026-11-10 14:26:28.000000000","message":"worx on my SAIO!\n\n```\nvagrant@saio:~$ swift-manage-shard-ranges $ROOT analyze --db\nLoaded db broker for AUTH_test/small-db\nFound one complete sequence of 2 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\nvagrant@saio:~$ swift-manage-shard-ranges $ROOT show \u003e /tmp/small-db-shards.json\nvagrant@saio:~$ swift-manage-shard-ranges /tmp/small-db-shards.json analyze\nFound one complete sequence of 2 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\n```\n\nOne thing I want to highlight though is that design-wise, I\u0027m not sure I\u0027m a fan of the ergonomics WRT specifying the type of file the user is opening. I thought maybe checking the file extension or something would be a good idea, but thinking about it that\u0027s a bit lossy/shortsighted since the user might avoid/forget to add the filetype to whatever `show` output json they\u0027re trying to check out.\n\nOne better alternative I have in mind to opening the broker db or doing the file extension thing is checking the initial bytes of the file to see if it\u0027s a sqlite file, which should avoid the quarantining issue + allow us to avoid adding another flag + probably make the workflow easier/smarter. A little bit like this:\n\n```\nwith open(path, \u0027rb\u0027) as f:\n    is_db \u003d f.read(16) \u003d\u003d b\u0027SQLite format 3\\x00\u0027\n    # and then we can just use is_db\n```","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"7130b901_ae924be7","in_reply_to":"3ccb87c1_862e1416","updated":"2026-11-13 23:23:12.000000000","message":"The sqlite header check was the first suggestion made by my agents. I decided against that approach because while it does solve the quarantine problem (NB: smsr will no longer attempt to quarantine a non-database file now that this change has merged: https://review.opendev.org/c/openstack/swift/+/1005958), it doesn\u0027t solve the same-file name problem pointed out in @matt@oliver.net.au\u0027s example tests. To wit: in the previous version of this patch, if you have a hash.json file sitting next to a hash.db, passing in the hash.json file will read the shard ranges from the database instead.\n\nMatt O pointed out that the same-file name situation is somewhat contrived, but that he considers it a bug nevertheless, and I tend to agree. This led me to the conclusion that the problem is the ambiguity in what the user wants and the tool trying to guess. I would personally prefer to specify intent in an unambiguous fashion and have the tool have built-in guardrails for foreseeable error cases. (More detail on what can go wrong in the same-name problem case described below in a response to Alistair.)\n\nA minor reason I didn\u0027t want to sniff the db file header is just that the SQLite library code already does it as part of opening the file, so it feels a bit redundant. I did verify that the file header is stable within a major version of SQLite so it is a valid thing to depend on. I can imagine the database auditor might eventually want to do this for helping to diagnose problems. I guess what I am saying is it is a reasonable approach in general, but doesn\u0027t feel like the right solution here.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":5,"id":"ddd0853c_a2736446","in_reply_to":"b1159e94_1b23e285","updated":"2026-11-13 23:23:12.000000000","message":"See reply below to Alistair on why I prefer to have the user make an explicit choice of what their intent it. I do think your suggestion to support both flags instead of just the non-default makes sense and I will adopt that aspect of your squash patch.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"210fda8c_170b3e34","updated":"2026-11-19 16:07:51.000000000","message":"This seems to work, with the exception of one error case spewing the contents of the db (see inline comment)\n\nWith my suggested fix to output a more compact json decode error message, I see:\n\ndb file:\n```\nvagrant@saio:~/swift$ swift-manage-shard-ranges /srv/node2/sdb2/containers/287/cd0/47c3e053ba24a95167deedca736a5cd0/47c3e053ba24a95167deedca736a5cd0.db analyze --json\nFailed to load valid shard range data: \u0027utf-8\u0027 codec can\u0027t decode byte 0xfb in position 106: invalid start byte\n\nvagrant@saio:~/swift$ swift-manage-shard-ranges /srv/node2/sdb2/containers/287/cd0/47c3e053ba24a95167deedca736a5cd0/47c3e053ba24a95167deedca736a5cd0.db analyze --db\nLoaded db broker for AUTH_test/container-8d9ae02b-7ac5-4c9a-91a6-171edd85fe5d\nFound one complete sequence of 3 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\n\nvagrant@saio:~/swift$ swift-manage-shard-ranges /srv/node2/sdb2/containers/287/cd0/47c3e053ba24a95167deedca736a5cd0/47c3e053ba24a95167deedca736a5cd0.db analyze\nLoaded db broker for AUTH_test/container-8d9ae02b-7ac5-4c9a-91a6-171edd85fe5d\nFound one complete sequence of 3 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\n```\n\njson file:\n```\nvagrant@saio:~/swift$ swift-manage-shard-ranges junk2 analyze --json\nFound one complete sequence of 3 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\n\nvagrant@saio:~/swift$ swift-manage-shard-ranges junk2 analyze\nError opening container DB junk2: not recognized as a container DB file. Use --json to analyze a shard data file.\n\nvagrant@saio:~/swift$ swift-manage-shard-ranges junk2 analyze --db\nError opening container DB junk2: not recognized as a container DB file. Use --json to analyze a shard data file.\n```\n\nOK: Reading from stdin with ``--json``:\n```\nvagrant@saio:~/swift$ swift-manage-shard-ranges - analyze --json  \u003cjunk2\nFound one complete sequence of 3 shard ranges and no overlapping shard ranges.\nNo repairs necessary.\n\n```\n\nThe error message when reading from stdin *without* ``--json`` is a little odd, but consistent with other commands:\n\n```\nvagrant@saio:~/swift$ swift-manage-shard-ranges - analyze \u003cjunk2\nError opening container DB -: DB connection error (/vagrant/swift/-, 0):\nDB doesn\u0027t exist\nvagrant@saio:~/swift$ swift-manage-shard-ranges - analyze\nError opening container DB -: DB connection error (/vagrant/swift/-, 0):\nDB doesn\u0027t exist\nvagrant@saio:~/swift$ swift-manage-shard-ranges - show\nError opening container DB -: DB connection error (/vagrant/swift/-, 0):\nDB doesn\u0027t exist\n```","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":38368,"name":"Christian Ohanaja","display_name":"Christian Ohanaja","email":"cohanaja@nvidia.com","username":"cohanaja"},"change_message_id":"ed89935cb85ed2086cb76c78f4888ae8eebeaa52","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"bac7bf75_c6102d90","updated":"2026-11-17 01:45:34.000000000","message":"hooray for quarantine_ok!","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"25041048a9b3d1e3000e67b67bdf94bbd16876e5","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"32a7467c_b101fe7d","in_reply_to":"210fda8c_170b3e34","updated":"2026-11-19 23:12:46.000000000","message":"Thanks for the review and thorough testing! PS7 addresses your inline comments (details below).\n\nI also picked up a few items from reviewbot:\n- analyze on a DB with no shard ranges now reports \"No shards found, nothing to do.\" and exits 0, like repair, instead of reporting gaps\n- the DB tests now include a deleted shard range, to check that analyze ignores it as repair does\n- removed an unused @with_tempdir from test_analyze_db_file","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"20c76752ed49611edcb211ff2d179ead1b94ddbb","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":7,"id":"ee2d2c86_bf085fa2","updated":"2026-11-20 12:14:19.000000000","message":"I think there is a discrepancy between the handling of no shard ranges when reading from a db vs a json file or stdin. However, I think the behaviour in this patch w.r.t. reading a db file makes mores sense i.e. report \u0027No shard ranges\u0027, exit 0.\n\nIdeally this patch would match the \u0027legacy\u0027 behaviour when loading a json file with an empty list, but that is arguably creeping the scope of this patch to (a) read from db files AND (b) fix legacy reporting of empty list.\n\nI could be persuaded to jump one of three ways:\n1. merge this as it is - it IS forwards progress, then fix the json loading in a follow on patch [1]\n2. revert recent change in this patch so that reading an empty list from a db reports \u0027no complete sequence\u0027 same as json, then fix that in a follow on patch.\n3. squash the follow on [1] into this patch\n\nI\u0027m inclined towards option 1. The discrepancy is not so egregious to justify blocking forwards progress. Make things even better after. But I\u0027d like Matthew to double check my understanding before I merge. For now, I\u0027m voting +1 pending a conversation with Matthew.\n\n[1] 1016669: smsr: make analyze of empty shard ranges not an error | https://review.opendev.org/c/openstack/swift/+/1016669","commit_id":"45c7652a564c9f8059da471be9add195b3a85193"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"de5f7bd602279f488b239d2b26abdd44976ac9de","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":7,"id":"bfacc6e5_9584e21a","updated":"2026-11-20 17:03:00.000000000","message":"let\u0027s capture this progress and move on to the follow patch","commit_id":"45c7652a564c9f8059da471be9add195b3a85193"}],"swift/cli/manage_shard_ranges.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"c5f3a3d51fe3ab07ffcd15ef43e62a4fe5662730","unresolved":true,"context_lines":[{"line_number":1217,"context_line":"                             logger\u003dlogger,"},{"line_number":1218,"context_line":"                             skip_commits\u003dargs.skip_commits)"},{"line_number":1219,"context_line":"    try:"},{"line_number":1220,"context_line":"        broker.get_info()"},{"line_number":1221,"context_line":"    except Exception as exc:"},{"line_number":1222,"context_line":"        if args.func in (analyze_shard_ranges,):"},{"line_number":1223,"context_line":"            # special case: analyze doesn\u0027t require a broker if path_to_file"}],"source_content_type":"text/x-python","patch_set":4,"id":"a0698d47_72037d1a","line":1220,"updated":"2026-09-30 07:14:37.000000000","message":"if a json is passed in there, the json will be opened here as an SQL db.. but fail and potentually be qurantined before the json fallback runs.","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"90fada582f46313f0c5b1b19db7e24500b86ee7d","unresolved":true,"context_lines":[{"line_number":1217,"context_line":"                             logger\u003dlogger,"},{"line_number":1218,"context_line":"                             skip_commits\u003dargs.skip_commits)"},{"line_number":1219,"context_line":"    try:"},{"line_number":1220,"context_line":"        broker.get_info()"},{"line_number":1221,"context_line":"    except Exception as exc:"},{"line_number":1222,"context_line":"        if args.func in (analyze_shard_ranges,):"},{"line_number":1223,"context_line":"            # special case: analyze doesn\u0027t require a broker if path_to_file"}],"source_content_type":"text/x-python","patch_set":4,"id":"e3a5da12_ace9d43d","line":1220,"in_reply_to":"a0698d47_72037d1a","updated":"2026-11-12 18:33:45.000000000","message":"IIUC this risk has been mitigated by the quarantine_ok flag.\n\nBut would also be avoided by trying to decode json first before trying to use a broker.","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":false,"context_lines":[{"line_number":1217,"context_line":"                             logger\u003dlogger,"},{"line_number":1218,"context_line":"                             skip_commits\u003dargs.skip_commits)"},{"line_number":1219,"context_line":"    try:"},{"line_number":1220,"context_line":"        broker.get_info()"},{"line_number":1221,"context_line":"    except Exception as exc:"},{"line_number":1222,"context_line":"        if args.func in (analyze_shard_ranges,):"},{"line_number":1223,"context_line":"            # special case: analyze doesn\u0027t require a broker if path_to_file"}],"source_content_type":"text/x-python","patch_set":4,"id":"2f2b718c_bc3451a6","line":1220,"in_reply_to":"e3a5da12_ace9d43d","updated":"2026-11-19 16:07:51.000000000","message":"Done","commit_id":"627e6be13009ed312c7c98a376bb249053992c77"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"08b8ec295e0360f2f82a8863a56e8f6cb6bf8959","unresolved":true,"context_lines":[{"line_number":882,"context_line":"        return repair_overlaps(broker, args)"},{"line_number":883,"context_line":""},{"line_number":884,"context_line":""},{"line_number":885,"context_line":"def analyze_shard_ranges(broker, args):"},{"line_number":886,"context_line":"    if broker is None:"},{"line_number":887,"context_line":"        # Without --db, analyze reads JSON shard data from file."},{"line_number":888,"context_line":"        shard_data \u003d _load_and_validate_shard_data(args, require_index\u003dFalse)"}],"source_content_type":"text/x-python","patch_set":5,"id":"e79bd624_9e4e306d","line":885,"updated":"2026-11-11 10:09:11.000000000","message":"how about assuming json and falling back to db:\n\n```\ndef analyze_shard_ranges(args):\n    try:\n        shard_data \u003d _load_shard_data(args.path_to_file)\n    except JSONDecodeError:\n        broker \u003d ContainerBroker(...)\n        shard_data \u003d [dict(sr) for sr in broker.get_shard_ranges()]\n    _validate_shard_data(shard_data)\n    ...\n``` \n\nnote refactoring of ``_load_and_validate_shard_data`` into two methods with only ``_validate_shard_data`` calling ``exit``","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[{"line_number":882,"context_line":"        return repair_overlaps(broker, args)"},{"line_number":883,"context_line":""},{"line_number":884,"context_line":""},{"line_number":885,"context_line":"def analyze_shard_ranges(broker, args):"},{"line_number":886,"context_line":"    if broker is None:"},{"line_number":887,"context_line":"        # Without --db, analyze reads JSON shard data from file."},{"line_number":888,"context_line":"        shard_data \u003d _load_and_validate_shard_data(args, require_index\u003dFalse)"}],"source_content_type":"text/x-python","patch_set":5,"id":"606c26bc_14093610","line":885,"in_reply_to":"e79bd624_9e4e306d","updated":"2026-11-13 23:23:12.000000000","message":"Reproducing out-of-band discussion here for posterity:\n\nTBH I got grossed out by the corner cases that @matt@oliver.net.au’s test illuminated, and just decided to make it explicit. Some issues that came up in @cohanaja@nvidia.com\u0027s proposed patch have reinforced that feeling.\n\nLet\u0027s assume that we adopt the approach of trying the json first instead of the database. If done naively, here are some examples of what can go wrong if there are same-name (modulo extension) json and database files present:\n\n1. Pass a broken json file. JSON parsing fails, we fall back to the database and the tool happily reports results from the wrong file.\n2. Pass a base database filename hash.db after sharding has completed. hash.db is gone and has been replaced with hash_\u003cepoch\u003e.db. Trying to parse as JSON first reports a file-not-found error and fails. (I don\u0027t know if people use these tools that way, but Claude reports all the other tools have this behavior.)\n\nObviously these are fixable and Claude estimates that it won\u0027t be any more code than the explicit version. But seeing these sorts of issues makes me think it would be a lot more straightforward to make the user\u0027s intent explicit. Future changes may make this harder to keep correct.","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"08b8ec295e0360f2f82a8863a56e8f6cb6bf8959","unresolved":true,"context_lines":[{"line_number":1216,"context_line":"        print(\u0027Invalid config: %s\u0027 % err, file\u003dsys.stderr)"},{"line_number":1217,"context_line":"        return EXIT_INVALID_ARGS"},{"line_number":1218,"context_line":""},{"line_number":1219,"context_line":"    if args.func in (analyze_shard_ranges,) and not args.db:"},{"line_number":1220,"context_line":"        # special case: analyze doesn\u0027t require a broker unless --db is given"},{"line_number":1221,"context_line":"        args.input \u003d args.path_to_file"},{"line_number":1222,"context_line":"        return args.func(None, args)"}],"source_content_type":"text/x-python","patch_set":5,"id":"6c11d8ee_735826c1","line":1219,"updated":"2026-11-11 10:09:11.000000000","message":"how about something like:\n```\ntry:\n    shard_data \u003d _load_json_shard_data(args.path_to_file)\nexcept JSONDecodeError:\n    broker \u003d ContainerBroker(...)\n    shard_data \u003d [dict(sr) for sr in broker.get_shard_ranges()]\n_analyze_shard_data(shard_data)\n```","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"6922ef8ed2897d1ab25434cdc8f2261e1fd83aa6","unresolved":true,"context_lines":[{"line_number":1216,"context_line":"        print(\u0027Invalid config: %s\u0027 % err, file\u003dsys.stderr)"},{"line_number":1217,"context_line":"        return EXIT_INVALID_ARGS"},{"line_number":1218,"context_line":""},{"line_number":1219,"context_line":"    if args.func in (analyze_shard_ranges,) and not args.db:"},{"line_number":1220,"context_line":"        # special case: analyze doesn\u0027t require a broker unless --db is given"},{"line_number":1221,"context_line":"        args.input \u003d args.path_to_file"},{"line_number":1222,"context_line":"        return args.func(None, args)"}],"source_content_type":"text/x-python","patch_set":5,"id":"ef9ec98a_e5e047a1","line":1219,"in_reply_to":"6c11d8ee_735826c1","updated":"2026-11-11 10:10:05.000000000","message":"oops, I meant to delete this duplicate suggestion","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"8db81130be3827194d590f17091e6320d2719f49","unresolved":false,"context_lines":[{"line_number":1216,"context_line":"        print(\u0027Invalid config: %s\u0027 % err, file\u003dsys.stderr)"},{"line_number":1217,"context_line":"        return EXIT_INVALID_ARGS"},{"line_number":1218,"context_line":""},{"line_number":1219,"context_line":"    if args.func in (analyze_shard_ranges,) and not args.db:"},{"line_number":1220,"context_line":"        # special case: analyze doesn\u0027t require a broker unless --db is given"},{"line_number":1221,"context_line":"        args.input \u003d args.path_to_file"},{"line_number":1222,"context_line":"        return args.func(None, args)"}],"source_content_type":"text/x-python","patch_set":5,"id":"ae5cfbef_2a6fd4f2","line":1219,"in_reply_to":"ef9ec98a_e5e047a1","updated":"2026-11-13 23:23:12.000000000","message":"Acknowledged","commit_id":"a81ab070ac18f261ae9cf909b1cb633ec0f2cdd1"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":true,"context_lines":[{"line_number":277,"context_line":"                        shard[k]  # trigger KeyError for missing required key"},{"line_number":278,"context_line":"                return data"},{"line_number":279,"context_line":"            except (TypeError, ValueError, KeyError) as err:"},{"line_number":280,"context_line":"                print(\u0027Failed to load valid shard range data: %r\u0027 % err,"},{"line_number":281,"context_line":"                      file\u003dsys.stderr)"},{"line_number":282,"context_line":"                exit(2)"},{"line_number":283,"context_line":"    except IOError as err:"}],"source_content_type":"text/x-python","patch_set":6,"id":"a6726d33_a0485faf","line":280,"range":{"start_line":280,"start_character":62,"end_line":280,"end_character":64},"updated":"2026-11-19 16:07:51.000000000","message":"we probably want this to be ``%s``\n\n```\ndiff --git a/swift/cli/manage_shard_ranges.py b/swift/cli/manage_shard_ranges.py\nindex 013c4141b..a22d2cdc4 100644\n--- a/swift/cli/manage_shard_ranges.py\n+++ b/swift/cli/manage_shard_ranges.py\n@@ -277,7 +277,7 @@ def _load_and_validate_shard_data(args, require_index\u003dTrue):\n                         shard[k]  # trigger KeyError for missing required key\n                 return data\n             except (TypeError, ValueError, KeyError) as err:\n-                print(\u0027Failed to load valid shard range data: %r\u0027 % err,\n+                print(\u0027Failed to load valid shard range data: %s\u0027 % err,\n                       file\u003dsys.stderr)\n                 exit(2)\n     except IOError as err:\n\n```","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"25041048a9b3d1e3000e67b67bdf94bbd16876e5","unresolved":false,"context_lines":[{"line_number":277,"context_line":"                        shard[k]  # trigger KeyError for missing required key"},{"line_number":278,"context_line":"                return data"},{"line_number":279,"context_line":"            except (TypeError, ValueError, KeyError) as err:"},{"line_number":280,"context_line":"                print(\u0027Failed to load valid shard range data: %r\u0027 % err,"},{"line_number":281,"context_line":"                      file\u003dsys.stderr)"},{"line_number":282,"context_line":"                exit(2)"},{"line_number":283,"context_line":"    except IOError as err:"}],"source_content_type":"text/x-python","patch_set":6,"id":"a6513d69_7492da84","line":280,"range":{"start_line":280,"start_character":62,"end_line":280,"end_character":64},"in_reply_to":"a6726d33_a0485faf","updated":"2026-11-19 23:12:46.000000000","message":"Done, with a small variation: the message now includes the exception type. (This message change also applies to the merge and replace commands.)","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":true,"context_lines":[{"line_number":885,"context_line":"def analyze_shard_ranges(broker, args):"},{"line_number":886,"context_line":"    if args.json:"},{"line_number":887,"context_line":"        # With --json, analyze reads JSON shard data from file."},{"line_number":888,"context_line":"        shard_data \u003d _load_and_validate_shard_data(args, require_index\u003dFalse)"},{"line_number":889,"context_line":"    else:"},{"line_number":890,"context_line":"        try:"},{"line_number":891,"context_line":"            shard_data \u003d [dict(sr) for sr in broker.get_shard_ranges()]"}],"source_content_type":"text/x-python","patch_set":6,"id":"a2dad9a3_6f9266b3","line":888,"updated":"2026-11-19 16:07:51.000000000","message":"misuse of --json gave rise to a very long error message to stderr with db contents:\n\n```$ swift-manage-shard-ranges /srv/node2/sdb2/containers/287/cd0/47c3e053ba24a95167deedca736a5cd0/47c3e053ba24a95167deedca736a5cd0.db analyze --json\nFailed to load valid shard range data: UnicodeDecodeError(\u0027utf-8\u0027, b\u0027SQLite format 3\\x00\\x10\\x00\\x01\\x01\\x00@  \\x00\\x00\\x0 ......\n```","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"25041048a9b3d1e3000e67b67bdf94bbd16876e5","unresolved":false,"context_lines":[{"line_number":885,"context_line":"def analyze_shard_ranges(broker, args):"},{"line_number":886,"context_line":"    if args.json:"},{"line_number":887,"context_line":"        # With --json, analyze reads JSON shard data from file."},{"line_number":888,"context_line":"        shard_data \u003d _load_and_validate_shard_data(args, require_index\u003dFalse)"},{"line_number":889,"context_line":"    else:"},{"line_number":890,"context_line":"        try:"},{"line_number":891,"context_line":"            shard_data \u003d [dict(sr) for sr in broker.get_shard_ranges()]"}],"source_content_type":"text/x-python","patch_set":6,"id":"832e9363_3fd854cb","line":888,"in_reply_to":"a2dad9a3_6f9266b3","updated":"2026-11-19 23:12:46.000000000","message":"Fixed and modified `test_analyze_db_file_with_json_option` to assert the db contents aren\u0027t dumped.","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"20c76752ed49611edcb211ff2d179ead1b94ddbb","unresolved":true,"context_lines":[{"line_number":895,"context_line":"            return EXIT_ERROR"},{"line_number":896,"context_line":"        if not shard_data:"},{"line_number":897,"context_line":"            print(\u0027No shards found, nothing to do.\u0027)"},{"line_number":898,"context_line":"            return EXIT_SUCCESS"},{"line_number":899,"context_line":"    for data in shard_data:"},{"line_number":900,"context_line":"        # allow for incomplete shard range data that may have been scraped from"},{"line_number":901,"context_line":"        # swift-container-info output"}],"source_content_type":"text/x-python","patch_set":7,"id":"50349df3_fb83b5f0","line":898,"updated":"2026-11-20 12:14:19.000000000","message":"good catch, but I don\u0027t think this matches the current behaviour when loading json.\n\nSee 1016669: smsr: make analyze of empty shard ranges not an error | https://review.opendev.org/c/openstack/swift/+/1016669","commit_id":"45c7652a564c9f8059da471be9add195b3a85193"}],"test/unit/cli/test_manage_shard_ranges.py":[{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"f20e1d51cdcc99e691c1479d1123aef8faf17999","unresolved":true,"context_lines":[{"line_number":1224,"context_line":"            [\u0027Error opening container DB %s: DB connection error (%s, 0):\u0027"},{"line_number":1225,"context_line":"             % (missing_file, missing_file),"},{"line_number":1226,"context_line":"             \"DB doesn\u0027t exist\"],"},{"line_number":1227,"context_line":"            err.getvalue().splitlines())"},{"line_number":1228,"context_line":""},{"line_number":1229,"context_line":"    def test_analyze_db_file_with_shard_range_read_error(self):"},{"line_number":1230,"context_line":"        broker \u003d self._make_broker()"}],"source_content_type":"text/x-python","patch_set":6,"id":"db06bb99_0a549354","line":1227,"updated":"2026-11-19 16:07:51.000000000","message":"this fails on my mac with:\n\n```\nFAILED\ntest/unit/cli/test_manage_shard_ranges.py:1214 (TestManageShardRanges.test_analyze_missing_file)\n[\u0027Error opening container DB \u0027\n \u0027/var/folders/5n/jty8zbg15rjfj5gqbkm3fkv00000gp/T/tmpmper_lky/tmp_test_cli_find_shards/missing.db: \u0027\n \u0027DB connection error \u0027\n \u0027(/private/var/folders/5n/jty8zbg15rjfj5gqbkm3fkv00000gp/T/tmpmper_lky/tmp_test_cli_find_shards/missing.db, \u0027\n \u00270):\u0027,\n \"DB doesn\u0027t exist\"] !\u003d [\u0027Error opening container DB \u0027\n \u0027/var/folders/5n/jty8zbg15rjfj5gqbkm3fkv00000gp/T/tmpmper_lky/tmp_test_cli_find_shards/missing.db: \u0027\n \u0027DB connection error \u0027\n \u0027(/var/folders/5n/jty8zbg15rjfj5gqbkm3fkv00000gp/T/tmpmper_lky/tmp_test_cli_find_shards/missing.db, \u0027\n \u00270):\u0027,\n \"DB doesn\u0027t exist\"]\n ```\n\n(note the actual exception string has the temp file prefixed with the ``/private`` folder :/ )\n\nwould you be prepared to change the test to not assert the detail of the sqlite3 exception message? i.e.:\n\n```\ndiff --git a/test/unit/cli/test_manage_shard_ranges.py b/test/unit/cli/test_manage_shard_ranges.py\nindex 841994448..8b049cda6 100644\n--- a/test/unit/cli/test_manage_shard_ranges.py\n+++ b/test/unit/cli/test_manage_shard_ranges.py\n@@ -1220,11 +1220,13 @@ class TestManageShardRanges(BaseUnitTestCase):\n             ret \u003d main([missing_file, \u0027analyze\u0027])\n         self.assertEqual(1, ret)\n         self.assertEqual(\u0027\u0027, out.getvalue())\n-        self.assertEqual(\n-            [\u0027Error opening container DB %s: DB connection error (%s, 0):\u0027\n-             % (missing_file, missing_file),\n-             \"DB doesn\u0027t exist\"],\n-            err.getvalue().splitlines())\n+        err_lines \u003d err.getvalue().splitlines()\n+        self.assertEqual(2, len(err_lines))\n+        self.assert_starts_with(\n+            err_lines[0],\n+            \u0027Error opening container DB %s: DB connection error\u0027\n+            % missing_file)\n+        self.assertEqual(\"DB doesn\u0027t exist\", err_lines[1])\n \n     def test_analyze_db_file_with_shard_range_read_error(self):\n         broker \u003d self._make_broker()\n\n```","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":39164,"name":"Matthew Allen","display_name":"Matthew Allen","email":"maallen@nvidia.com","username":"matthewallen"},"change_message_id":"25041048a9b3d1e3000e67b67bdf94bbd16876e5","unresolved":false,"context_lines":[{"line_number":1224,"context_line":"            [\u0027Error opening container DB %s: DB connection error (%s, 0):\u0027"},{"line_number":1225,"context_line":"             % (missing_file, missing_file),"},{"line_number":1226,"context_line":"             \"DB doesn\u0027t exist\"],"},{"line_number":1227,"context_line":"            err.getvalue().splitlines())"},{"line_number":1228,"context_line":""},{"line_number":1229,"context_line":"    def test_analyze_db_file_with_shard_range_read_error(self):"},{"line_number":1230,"context_line":"        broker \u003d self._make_broker()"}],"source_content_type":"text/x-python","patch_set":6,"id":"9be21b80_4099454d","line":1227,"in_reply_to":"db06bb99_0a549354","updated":"2026-11-19 23:12:46.000000000","message":"Thanks for catching this. Rather than loosening the assertion, I made the test expect the real path.","commit_id":"b399861179d4e6e6eb88ffe6e47bdbc0e9d4e7b4"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"20c76752ed49611edcb211ff2d179ead1b94ddbb","unresolved":true,"context_lines":[{"line_number":1223,"context_line":"        # tempdir path, e.g. /private/var vs /var on macOS"},{"line_number":1224,"context_line":"        self.assertEqual("},{"line_number":1225,"context_line":"            [\u0027Error opening container DB %s: DB connection error (%s, 0):\u0027"},{"line_number":1226,"context_line":"             % (missing_file, os.path.realpath(missing_file)),"},{"line_number":1227,"context_line":"             \"DB doesn\u0027t exist\"],"},{"line_number":1228,"context_line":"            err.getvalue().splitlines())"},{"line_number":1229,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"ad4a3a3c_5471b605","line":1226,"updated":"2026-11-20 12:14:19.000000000","message":"nice","commit_id":"45c7652a564c9f8059da471be9add195b3a85193"}]}
