build(intake): add the Anthropic SDK and warn when its key is absent (#223)
Both packages go in dependencies rather than devDependencies. The final Docker stage installs with --omit=dev, so the wrong section produces a container that fails on the first submission and nowhere else — which is how sharp went wrong in #226. ANTHROPIC_API_KEY is a warning, not a requirement. Absent, the container still boots and a submission still arrives, keeps its photos and waits in the queue undrafted. The photos are often the only copy of an item no longer in the sender's hands, so losing a consignment to an expired key would be a worse outcome than an item arriving without its description written. Silence would be wrong too: an operator who believes drafting is on and finds every item undrafted has nothing to tell them why. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,4 +215,25 @@ describe('UPLOADS_BASE_URL', () => {
|
||||
const { errors } = validateEnv(withEnv({ UPLOADS_BASE_URL: '/uploads' }));
|
||||
expect(errors).toContainEqual(expect.stringContaining('absolute origin'));
|
||||
});
|
||||
// #223. MINIMAL deliberately has no ANTHROPIC_API_KEY, so it is already the
|
||||
// absent case.
|
||||
describe('the intake drafting key', () => {
|
||||
// Absent is a working configuration, so this must never reach the errors
|
||||
// list. A submission that arrives undrafted is a far better outcome than a
|
||||
// container that will not boot.
|
||||
it('is not required', () => {
|
||||
expect(validateEnv(MINIMAL).errors).toEqual([]);
|
||||
});
|
||||
|
||||
// But silence would be worse than a warning: an operator who thinks
|
||||
// drafting is on and finds every item undrafted has no way to tell why.
|
||||
it('warns when it is absent', () => {
|
||||
expect(validateEnv(MINIMAL).warnings.join(' ')).toMatch(/ANTHROPIC_API_KEY/);
|
||||
});
|
||||
|
||||
it('says nothing when it is set', () => {
|
||||
const { warnings } = validateEnv(withEnv({ ANTHROPIC_API_KEY: 'sk-ant-test' }));
|
||||
expect(warnings.join(' ')).not.toMatch(/ANTHROPIC_API_KEY/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user