From 08ac7fd6b9141190497615dbbbc7fd381c95803e Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Carle <29762210+jscarle@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:50:36 -0400 Subject: [PATCH] Removed stale TODO items and clarified custom-template edits. --- .../OnePasswordManagerCommandTests.cs | 31 +++++++++++ README.md | 2 + TODO.md | 51 ++----------------- docfx/docs/quick-start.md | 2 + 4 files changed, 38 insertions(+), 48 deletions(-) diff --git a/OnePassword.NET.Tests/OnePasswordManagerCommandTests.cs b/OnePassword.NET.Tests/OnePasswordManagerCommandTests.cs index 34c1234..da3d181 100644 --- a/OnePassword.NET.Tests/OnePasswordManagerCommandTests.cs +++ b/OnePassword.NET.Tests/OnePasswordManagerCommandTests.cs @@ -2,6 +2,7 @@ using System.IO.Compression; using System.Reflection; using System.Runtime.InteropServices; +using System.Text.Json; using OnePassword.Common; using OnePassword.Documents; using OnePassword.Items; @@ -281,6 +282,30 @@ public void EditItemFailureKeepsItemDirty() Assert.That(IsTrackedChanged(item), Is.True); } + [Test] + public void EditItemPreservesCustomTemplateCategoryIdInPayload() + { + using var fakeCli = new FakeCli(); + var manager = fakeCli.CreateManager(); + var item = CreateTrackedItem("item-id", "Custom Item"); + item.CategoryId = "custom-template-uuid"; + item.Fields.Add(new Field("Environment", FieldType.String, "Production")); + + manager.EditItem(item, "vault-id"); + + using var jsonDocument = JsonDocument.Parse(fakeCli.LastInput); + var root = jsonDocument.RootElement; + var fields = root.GetProperty("fields").EnumerateArray().ToList(); + + Assert.Multiple(() => + { + Assert.That(root.GetProperty("category_id").GetString(), Is.EqualTo("custom-template-uuid")); + Assert.That(fields.Any(field => + field.GetProperty("label").GetString() == "Environment" + && field.GetProperty("value").GetString() == "Production"), Is.True); + }); + } + [Test] public void ShareItemWithoutEmailsOmitsEmailsFlag() { @@ -416,6 +441,7 @@ private sealed class FakeCli : IDisposable private readonly string _argumentsPath; private readonly string _directoryPath; private readonly string _errorOutputPath; + private readonly string _inputPath; private readonly string _nextOutputPath; private readonly string _updateMessagePath; private readonly string _updatePayloadPath; @@ -427,6 +453,7 @@ public FakeCli(string versionOutput = "2.32.1\n", string nextOutput = "{}", stri _directoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); _argumentsPath = Path.Combine(_directoryPath, "last-arguments.txt"); _errorOutputPath = Path.Combine(_directoryPath, "error-output.txt"); + _inputPath = Path.Combine(_directoryPath, "last-input.txt"); _nextOutputPath = Path.Combine(_directoryPath, "next-output.txt"); _updateMessagePath = Path.Combine(_directoryPath, "update-output.txt"); _updatePayloadPath = Path.Combine(_directoryPath, "update-payload.zip"); @@ -460,6 +487,8 @@ public FakeCli(string versionOutput = "2.32.1\n", string nextOutput = "{}", stri public string LastArguments => File.Exists(_argumentsPath) ? File.ReadAllText(_argumentsPath) : ""; + public string LastInput => File.Exists(_inputPath) ? File.ReadAllText(_inputPath) : ""; + public OnePasswordManager CreateManager() { return new OnePasswordManager(options => @@ -500,6 +529,7 @@ private static string GetScript(string versionOutputFileName) @echo off setlocal > "%~dp0last-arguments.txt" echo %* + > "%~dp0last-input.txt" more if "%~1"=="update" ( if exist "%~dp0update-payload.zip" copy /y "%~dp0update-payload.zip" "%~3\update-payload.zip" > nul if exist "%~dp0update-output.txt" type "%~dp0update-output.txt" @@ -519,6 +549,7 @@ @echo off #!/bin/sh script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd) printf '%s' "$*" > "$script_dir/last-arguments.txt" + cat > "$script_dir/last-input.txt" if [ "$1" = "update" ]; then if [ -f "$script_dir/update-payload.zip" ]; then cp "$script_dir/update-payload.zip" "$3/update-payload.zip" diff --git a/README.md b/README.md index 784265c..0f6cd08 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,8 @@ itemToExtend.Fields.Add(new Field("Environment", FieldType.String, "Production") onePassword.EditItem(itemToExtend, vault); ``` +The same hydrate-edit-save flow applies to items based on custom templates. Fetch the hydrated item with `GetItem(...)` before editing so the wrapper preserves the item's template-backed `category_id` in the edit payload. + ### Adding file attachments to an item ```csharp diff --git a/TODO.md b/TODO.md index e40a58b..b9cfcd0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,52 +1,7 @@ # TODO -Current snapshot as of 2026-03-08. +Current snapshot as of 2026-03-09. -Historical debugging notes and completed issue/PR triage were removed from this file after the related work landed. The remaining current items are below. +Historical debugging notes and completed issue/PR triage were removed from this file after the related work landed. -## Priority Order - -1. Decide whether to merge, supersede, or close PR #84. -2. Verify whether Issue #85 still reproduces for custom-template items. - -## Open Pull Requests - -### PR #84 - Add Support for Referencing Files Object in Item Class - -Link: -- https://github.com/jscarle/OnePassword.NET/pull/84 - -Current assessment: -- Still lower priority than the bug-fix work already merged. -- Additive and potentially useful, but not merge-ready as-is. -- The PR only adds read-only file metadata exposure. - -Outstanding concerns: -- No tests were added. -- No README or docfx documentation was added. -- The public type name `File` is easy to confuse with `System.IO.File`. - -Recommended next step: -- If attachment metadata matters soon, either update PR #84 or reimplement it with: - - deserialization coverage for the `files` payload - - documentation that the feature is read-only metadata - - explicit consideration of the public type name -- Otherwise, leave it deferred. - -## Open Issues - -### Issue #85 - Example on how to add Fields to an existing item? - -Link: -- https://github.com/jscarle/OnePassword.NET/issues/85 - -Current assessment: -- The built-in item flow is now covered and documented: - - `OnePassword.NET.Tests/TestItems.cs` includes `EditItemAddsNewField()` - - `README.md` and `docfx/docs/quick-start.md` show hydrating with `GetItem(...)` before adding a field -- The remaining uncertainty is the issue comment pointing to custom-template behavior related to PR #81. - -Recommended next step: -- Reproduce the scenario specifically against a custom-template item. -- If it does not reproduce, close the issue as stale or already addressed by current behavior and docs. -- If it does reproduce, treat it as a targeted custom-template compatibility bug and add focused regression coverage before changing product code. +There are no active engineering follow-up items currently tracked in this file. diff --git a/docfx/docs/quick-start.md b/docfx/docs/quick-start.md index e318370..2451053 100644 --- a/docfx/docs/quick-start.md +++ b/docfx/docs/quick-start.md @@ -110,6 +110,8 @@ itemToExtend.Fields.Add(new Field("Environment", FieldType.String, "Production") onePassword.EditItem(itemToExtend, vault); ``` +The same hydrate-edit-save flow applies to items based on custom templates. Fetch the hydrated item with `GetItem(...)` before editing so the wrapper preserves the item's template-backed `category_id` in the edit payload. + ### Adding file attachments to an item ```csharp