Runbook: PVC Connect Integrations Service
Deploy
- Build and push the image (
docker build -t <registry>/pvc-connect-integrations:<tag> .). - Create or update the
integrations-secretsSecret (seedeploy/k8s/secret.template.yaml). - Run the migration Job (
deploy/k8s/migrate-job.yaml, image argmigrate) and wait for it to complete. - Apply
deploy/k8s(kustomize). The API rolls with zero unavailable pods; the Worker restarts.
The API needs only the database to be ready. AvaTax and RabbitMQ problems degrade the service; they never take
pods out of rotation. Check /health/providers for the tax provider and /health/bus for RabbitMQ.
Go-live checklist per entity
PUT /api/v1/admin/entities/{id}with the AvaTax company code and numeric company id, base currency and GL accounts.- Load tax-code mappings (from Avalara Tax Research) for every work type / sub type / trade in use, per category.
- Turn on flags in stages:
taxEstimates→salesTaxDocuments/useTaxDocuments(saved, not committed) → compare with the current process →commitDocuments. Turn onpartySyncandcertificatesonly once the NDA is signed. Turn oncanadaTaxonly for entities with Canadian registration configured in AvaTax. - Switch
AvaTax__EnvironmenttoProductionand set production credentials.
Sandbox smoke test (once credentials exist)
Run against the AvaTax sandbox with Tax__Provider=AvaTax, AvaTax__Environment=Sandbox:
- TX job site, labor + material lines → state/county/city breakdown in the response
- Ohio ZIP that spans jurisdictions →
POST /api/v1/addresses/validatereturns Rooftop/Interpolated quality - AP bill, then commit → visible in the AvaTax portal as a committed PurchaseInvoice
- ON job site on a CAD entity with a USD invoice → HST line, exchange rate stamped on the AvaTax transaction
- Credit against the invoice → ReturnInvoice in AvaTax, negative lines in
/reports/sales-tax
Common situations
| Symptom | What it means | Action |
|---|---|---|
Documents in PendingTax, TaxCalculationDeferred events | AvaTax unreachable, throttling, or failing auth | Check /health/providers and provider_call_audit (error codes). The recalculation job catches up on its own. Force a run with POST /api/v1/admin/jobs/tax-pending-recalculation/run. |
StalePending reconciliation issues | A document has been pending for more than 24 h | Usually credentials or configuration (401/403 count as unavailable). Fix, then run the job. |
422 provider_rejected / Failed documents | AvaTax refused the data (address, tax code, company) | The details say why. The caller resends corrected content with the same source id. |
409 feature_disabled | The entity has not enabled that feature | Intended during phased rollout. Enable it on the entity if it is time. |
409 party_not_synced | Certificate call for a customer/vendor not yet in Avalara | PUT the party (needs partySync on). |
MissingInProvider / TaxMismatch issues | Our committed document and AvaTax disagree | Compare in the AvaTax portal by providerDocumentCode. Recalculating or crediting fixes most. Resolve with POST /api/v1/reports/reconciliation-issues/{id}/resolve. |
MissingLocally issues | AvaTax has committed documents this service did not create | Another integration or manual entry is writing to the same AvaTax company. Find out who. |
FX provider_unavailable | No publication within the lookback window (source down for over 7 days) | Check the Bank of Canada Valet API. Backfill with POST /api/v1/fx/import. |
Messages in *_error queues | Invalid payloads, rejections, disabled features, or a message still failing after all redeliveries. | Read the MT-Fault-* headers, fix the sender or the configuration, then replay them. |
Rows piling up in deferred_messages | Messages waiting for something: the original document, a commit, AvaTax | Expected for minutes during an AvaTax outage. Check reason; a growing original_not_received count means a sender isn't publishing the invoices. |
403 entity_forbidden for an admin token | integrations:admin no longer implies entity access | Give the client entities:all or entity claims for the entities it manages. |
EntityAccessDeniedException faults in *_error | A message from a broker user not in Messaging__Publishers, without user_id, or for an entity that publisher may not touch | Check the message's user_id and entity. Add the publisher or entity to Messaging__Publishers__<user>__Entities, or fix the sender; then replay. |
429 responses | A client (or, for anonymous traffic, an IP) went over its per-minute budget | Normal back-pressure; clients retry after Retry-After. Raise RateLimiting__*PermitsPerMinute only for a known batch. Behind a proxy, check Http__ForwardedHeaders is on, or every caller shares the proxy's IP. |
| A job's last success is old | The job fails, or no Worker is running | GET /api/v1/admin/jobs shows lastError; run it now with POST /api/v1/admin/jobs/{name}/run (409 if it's already running). |
Useful queries
-- Pending/failed documents
select id, entity_id, source_system, source_document_id, status, status_reason, next_attempt_at
from integrations.tax_documents where status in ('PendingTax','Failed') order by updated_at desc;
-- AvaTax call failures in the last day
select operation, error_code, count(*) from integrations.provider_call_audit
where not succeeded and occurred_at > now() - interval '1 day' group by 1, 2 order by 3 desc;
-- Rates locked today
select from_currency, to_currency, rate, observation_date, created_by from integrations.rate_locks
where rate_date = current_date;
-- Messages parked for redelivery, by reason (see ADR 0008)
select message_type, split_part(reason, ':', 1) as reason, count(*), min(next_attempt_at) as next_due, max(attempt) as max_attempt
from integrations.deferred_messages group by 1, 2 order by 3 desc;
-- Events waiting in the outbox (should drain within seconds while RabbitMQ is up)
select count(*), min(sent_time) as oldest from integrations.outbox_message;
-- Scheduled jobs: last start, success and failure
select name, last_started_at, last_succeeded_at, last_failed_at, last_error from integrations.job_runs order by name;
-- Who committed, voided or credited a document, or changed configuration (append-only; see Security)
select occurred_at, caller_id, action, entity_id, subject_id, details from integrations.admin_audit
where subject_id = '<document, mapping, issue or request id>' or entity_id = 'PVC' order by occurred_at desc limit 50;
-- Who created and last changed a document (token client id, bus:<publisher> or system:<job>)
select id, created_by, modified_by, updated_at from integrations.tax_documents where source_document_id = 'INV-1001';
Broker users for publishers
To trust each publishing service only for its own entities (Messaging__Publishers, see
Security):
- One broker user per publishing service, writing only to the exchanges it publishes
(
rabbitmqctl set_permissions -p pvc-production sage "^$" "^pvc\.integrations\.(vendor-bill-approved|vendor-upserted)$" "^$"). - The publisher sets the AMQP
user_idproperty to its user on every message. With MassTransit:cfg.ConfigurePublish(p => p.UseExecute(c => { if (c.TryGetPayload<RabbitMqSendContext>(out var r)) r.BasicProperties.UserId = "sage"; })). - List it here:
Messaging__Publishers__sage__Entities__0=PVC(*for every entity). Deploy, then watch the_errorqueues forEntityAccessDeniedExceptionfaults.
Replaying error queues
Each consumer queue has a <queue>_error companion (e.g. credit-memo-issued_error). Messages land there when they
are invalid, rejected, or still failing after the last redelivery; the MT-Fault-Message and MT-Fault-StackTrace
headers say why.
- Fix the cause (sender data, entity configuration, feature flag).
- Move the messages back with the RabbitMQ management UI (Queues →
<queue>_error→ Move messages to<queue>, needs the shovel plugin) orrabbitmqadmin. They are processed again from the start; consumers are idempotent on the caller's ids, so replaying a message that partly succeeded is safe. - Messages that should never be processed: purge them from the
_errorqueue after noting the source ids.