Commit a3d54e9
fix(projects): nullify empty strings on permissions update payload (#673)
* fix(projects): nullify empty strings on permissions update payload
LFXV2-1724
Upstream LFX_V2_SERVICE rejects empty strings on validated fields in
the project settings PUT body. The prior workaround only omitted the
avatar key when empty; other fields (email, name, optional user refs)
echoed empty strings back to the upstream and could fail validation.
Introduces a generic, non-mutating nullifyEmptyStrings helper in
@lfx-one/shared/utils (new object.utils.ts) and applies it to the full
settings payload before the ETag PUT in ProjectService.
Signed-off-by: Asitha de Silva <asithade@gmail.com>
* fix(review): address PR #673 review feedback
Address review comments from copilot-pull-request-reviewer, coderabbitai:
- packages/shared/src/utils/object.utils.ts: introduce NullifyEmptyStrings<T>
mapped return type so callers see accurate nullability for nested string
fields, removing the unsound `T` return when T is `string` (per
copilot-pull-request-reviewer). The mapped type also flows through to the
ProjectSettings call site, resolving the runtime/declared type divergence
flagged on project.service.ts.
- packages/shared/src/utils/object.utils.ts: guard the object branch with a
plain-prototype check so Date, Map, Set, URL, RegExp, and class instances
are returned unchanged instead of being rebuilt into bare records (per
copilot-pull-request-reviewer and coderabbitai).
Resolves 4 review threads.
Signed-off-by: Asitha de Silva <asithade@gmail.com>
* refactor(shared): move NullifyEmptyStrings type to interfaces folder
Per repo convention, type aliases live alongside interfaces in
@lfx-one/shared/interfaces, not in utils files. Also flatten the
mapped type into single-conditional aliases so there are no chained
(nested) ternaries.
- packages/shared/src/interfaces/object.interface.ts: new home for
NullifyEmptyStrings<T>, split into NullifyStringBranch /
PreservedBranch / ArrayBranch / ObjectBranch helpers, each with a
single conditional.
- packages/shared/src/utils/object.utils.ts: imports the type from
interfaces and keeps only the runtime helper.
Signed-off-by: Asitha de Silva <asithade@gmail.com>
* fix(review): address PR #673 review feedback
Address review comment from copilot[bot]:
- packages/shared/src/utils/object.utils.ts: use Object.defineProperty
when rebuilding plain objects to prevent prototype pollution via
__proto__ keys (per copilot[bot])
Resolves 1 review thread.
Signed-off-by: Asitha de Silva <asithade@gmail.com>
* fix(review): address PR #673 review feedback
Address review comments from copilot[bot]:
- packages/shared/src/interfaces/object.interface.ts: add function branch
to NullifyEmptyStrings so callable types are preserved instead of being
mapped into their key records (per copilot[bot])
- packages/shared/src/utils/object.utils.ts: rename `trimmed` to
`nullIfBlank` since the value is the original string or null, not the
trimmed string (per copilot[bot])
Resolves 2 review threads.
Signed-off-by: Asitha de Silva <asithade@gmail.com>
---------
Signed-off-by: Asitha de Silva <asithade@gmail.com>
Signed-off-by: David Deal <ddeal@linuxfoundation.org>
Co-authored-by: David Deal <ddeal@linuxfoundation.org>1 parent 6415a29 commit a3d54e9
5 files changed
Lines changed: 75 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 456 | + | |
| 457 | + | |
481 | 458 | | |
482 | 459 | | |
483 | 460 | | |
| |||
491 | 468 | | |
492 | 469 | | |
493 | 470 | | |
494 | | - | |
| 471 | + | |
495 | 472 | | |
496 | 473 | | |
497 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
151 | 154 | | |
152 | 155 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments