Skip to content

Simplify feed generation internals by splitting response building and shared feed flow #1092

@Abhijeet17o

Description

@Abhijeet17o

Hi, I want to propose a backend refactor for feeds that keeps behavior the same but makes the code much easier to maintain.

Right now, too much feed logic is concentrated in one place and endpoint setup is repeated across views:

  1. Large multi-format response logic lives in utils.py.
  2. Similar request setup is repeated in feeds.py.
  3. Parameter handling, queryset construction, and output formatting are tightly coupled in utils.py.

What I propose to implement:

  1. Keep the existing feeds_response entrypoint, but split format-specific paths into internal handlers:
  2. json handler
  3. csv handler
  4. txt handler
  5. stix21 handler
  6. Extract shared feed setup flow used by feed endpoints so common logic is centralized (request params normalization, defaults/prioritization, queryset prep).
  7. Preserve current API contract and endpoint behavior, including pagination/auth/throttling behavior.

Target files:

  1. utils.py
  2. feeds.py

Validation:

  1. Ensure existing tests still pass, especially test_feeds_view.py and test_feeds_advanced_view.py.
  2. Add focused regression tests for format parity and dispatcher behavior if needed.

This is not a feature rewrite and not an architecture change, just a behavior-preserving internal simplification to reduce future risk and improve maintainability

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions