Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Fixed
- Treat Proofpoint create success items that carry `primary_email`/`email` (users) or
`name` (domains) with no error fields as succeeded, so `users_create` no longer
reports created users as unconfirmed.
- Share email redaction and Unicode-safe error limits across error boundaries; redact
domain-tool hostnames and reduce vendor errors to status/code metadata.
- Clean failed and unconfirmed create results, including error-bearing 201 objects
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ not scoped to a single org).
- `proofpoint_essentials_users_update` ⚠ high-impact
- `proofpoint_essentials_users_delete` ⚠ destructive, irreversible

The create serialization and result normalization fix requires `@wyre-ai/node-proofpoint-essentials >= 1.0.2`, which this package depends on.
The create serialization and result normalization fix requires `@wyre-ai/node-proofpoint-essentials >= 1.0.2`.
`users_create` / `domains_create` treat a returned User (`primary_email`) or Domain (`name`) with no error fields as succeeded even when Proofpoint omits `status`/`success`.
The single-user `users_get` path fix needs `@wyre-ai/node-proofpoint-essentials >= 1.1.1`, which this package depends on.

### Endpoint discovery
- `proofpoint_essentials_endpoint_discover` — resolve which region hosts a customer domain
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@modelcontextprotocol/node": "^2.0.0-beta.5",
"@modelcontextprotocol/server": "^2.0.0-beta.5",
"@wyre-ai/node-proofpoint-essentials": "^1.0.2"
"@wyre-ai/node-proofpoint-essentials": "^1.1.1"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
Expand Down
26 changes: 20 additions & 6 deletions src/__tests__/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,15 @@ describe.each(["users", "domains"] as const)("%s create batch results", (resourc
succeeded: 0, failed: 1, unconfirmed: 0,
},
{
name: "unconfirmed items",
results: [{ primary_email: "unknown@acme.com" }, { message: "accepted" }],
name: "Proofpoint resource identity without status is succeeded",
results: resource === "users"
? [{ primary_email: "created@acme.com", firstname: "Created" }]
: [{ name: "created.acme.com", is_relay: true }],
succeeded: 1, failed: 0, unconfirmed: 0,
},
{
name: "unconfirmed items without identity or status",
results: [{ message: "accepted" }, {}],
succeeded: 0, failed: 0, unconfirmed: 2,
},
{
Expand Down Expand Up @@ -317,14 +324,21 @@ describe.each(["users", "domains"] as const)("%s create batch results", (resourc
expect(result.isError).toBe(failed > 0 ? true : undefined);
const text = result.content[0].text;
const payload = JSON.parse(failed > 0 ? text.slice(text.indexOf("\n\n") + 2) : text);
const expectedOutcome = (item: BatchItemResult): "succeeded" | "failed" | "unconfirmed" => {
const codes = [item.status, item.code].filter((value): value is number => typeof value === "number");
const hasIdentity = (resource === "users"
? [item.primary_email, item.email]
: [item.name]
).some((value) => typeof value === "string" && value.trim() !== "");
if (item.success === false || codes.some((code) => code < 200 || code >= 300)) return "failed";
if (item.success === true || codes.length > 0 || hasIdentity) return "succeeded";
return "unconfirmed";
};
expect(payload).toEqual({
summary: { requested: Math.max(submitted, results.length), returned: results.length, succeeded, failed, unconfirmed },
results: succeeded !== results.length || unconfirmed > 0 ? original.map((item, index) => ({
index,
outcome: item.success === false || [item.status, item.code].some(
(code) => typeof code === "number" && (code < 200 || code >= 300)
) ? "failed" : item.success === true || typeof item.status === "number" || typeof item.code === "number"
? "succeeded" : "unconfirmed",
outcome: expectedOutcome(item),
...(typeof item.status === "number" ? { status: item.status } : {}),
...(typeof item.code === "number" ? { code: item.code } : {}),
...(typeof item.message === "string" ? { message: item.message } : {}),
Expand Down
15 changes: 14 additions & 1 deletion src/__tests__/sanitize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,23 @@ describe("error boundaries", () => {
it.each([
{ success: true, status: 201, error: null },
{ success: true, status: 201, errors: [] },
{ primary_email: "created@acme.com", firstname: "Created", surname: "User" },
])("keeps raw results for a confirmed success with an empty error field %j", (item) => {
const result = batchCreateResult("user", [item] as BatchItemResult[], 1);
expect(result.isError).toBeUndefined();
expect(JSON.parse(result.content[0].text).results).toEqual([item]);
const payload = JSON.parse(result.content[0].text);
expect(payload.summary).toEqual({
requested: 1, returned: 1, succeeded: 1, failed: 0, unconfirmed: 0,
});
expect(payload.results).toEqual([item]);
});
it("treats a Proofpoint Domain create body as succeeded without status/success", () => {
const item = { name: "created.acme.com", is_relay: true };
const result = batchCreateResult("domain", [item] as BatchItemResult[], 1);
expect(result.isError).toBeUndefined();
const payload = JSON.parse(result.content[0].text);
expect(payload.summary.succeeded).toBe(1);
expect(payload.results).toEqual([item]);
});
it.each([
{ error: "bob@x.com exists" },
Expand Down
8 changes: 7 additions & 1 deletion src/handlers/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ export function batchCreateResult(
const hasError = (value: unknown): boolean =>
value !== undefined && value !== null && value !== "" && value !== false &&
!(Array.isArray(value) && value.length === 0);
// Proofpoint postUser 201 returns a User (required primary_email); postDomain returns a Domain (required name).
// Batch 207 success items often carry the created resource identity with no status/success flag.
const hasProofpointSuccessIdentity = (kind === "user"
? [record.primary_email, record.email]
: [record.name]
).some((value) => typeof value === "string" && value.trim() !== "");
if (hasError(record.error) || hasError((record as { errors?: unknown }).errors) || record.success === false || codes.some((code) => code < 200 || code >= 300)) {
outcome = "failed";
} else if (record.success === true || codes.length > 0) {
} else if (record.success === true || codes.length > 0 || hasProofpointSuccessIdentity) {
outcome = "succeeded";
} else {
outcome = "unconfirmed";
Expand Down
Loading